use Time::Local; #require "dev_reg_lib_admin_v1_1.pm"; require "reg_lib_admin_v1_1.pm"; ############# V 1.1 ############################################################### ### Define any globals ############################################################### #my $org_url = "teamdev2"; $method = "post"; #Use Post for production, it hides the parameters. #my $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; #my $paypal_acc = "jeremyhlmclean\@yahoo.com"; #my $paypal_acc = "jeremy_1195331242_biz\@yahoo.com"; #my $paypal_acc = "jeremymclean\@gmail.com"; #my $paypal_acc = "lyaaball\@comcast.net"; #my $admin_url = "regadmin.html"; #my $admin_reg_url = "reg.html"; #my $thanks_url = "https://www.hometeamzonline.com/$org_url/$admin_reg_url?action=pp"; #my $ipn_url = "http://www.hometeamzonline.com/pp/ipn.php"; #my $base_reg_url = "https://www.hometeamzonline.com/$org_url/$admin_reg_url"; #my $paypal_acc = "jeremymclean\@gmail.com"; #my $paypal_url = "https://www.paypal.com/cgi-bin/webscr"; #my $thanks_url = "https://www.hometeamzonline.com/$org_url/thanks.html?transaction="; $phone_example = "Format 847-999-9999"; sub check_transaction_user{ my $session = shift; my $transaction_id = shift; my $valid = 0; my $session_user = get_user_by_session($session); my $txn_user = get_user_by_transaction($transaction_id); #print "SESSION USER: $session_user
\n"; #print "TXN_USER: $txn_user
\n"; if(($session_user != 0)&&($txn_user != 0)){ if($session_user == $txn_user){ $valid = 1; } } return $valid; } sub get_user_by_transaction{ my $transaction_id = shift; my $dbh = get_dbh(); my $return_key = 0; ################################################################ # Query DB for tranasctions ################################################################ my $query = "SELECT `Account_ID` FROM `Reg_Paypal` WHERE `Transaction_ID` = '$transaction_id'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_key = $Key; } $sth->finish(); $dbh->disconnect; return $return_key; } sub get_user_by_session{ my $session = shift; my $dbh = get_dbh(); my $return_key = 0; ################################################################ # Query DB for tranasctions ################################################################ my $query = "SELECT `Key` FROM `Account_Info` WHERE `Last_Access_ID` = '$session'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_key = $Key; } $sth->finish(); $dbh->disconnect; return $return_key; } ################################################################ ### This is the admin Sub routing for the home page ################################################################ sub admin_registration{ $failed_login = 0; ############################################################### ### Get paramters ############################################################### $page = param('page'); $sub = param('sub'); $coach = param('coach'); $newnews = param('news'); $title = param('title'); $date = param('date'); $update = param('update'); $obj_id = param('obj_id'); $month = param('month'); $year = param('year'); $day = param('day'); #$org_id = param('org_id'); $league_id = param('league_id'); $user = param('user'); $pass = param('pass'); $filter = param('filter'); $admin = param('admin'); $info_id = param('info_id'); $login = param('login'); $personal = param('personal'); $action = param('action'); $newemail = param('newemail'); if(!(defined($action))){$action = "";} ############################################################### ### Print Header ############################################################### %site_info = get_site_info($org_id); $site_info{"site_banner_image"} =~ s/\/home\/homete3\/public_html//; $site_info{"site_logo"} =~ s/\/home\/homete3\/public_html//; print header(); print ''; print_start_header_main(); print_style2(); ############################################################### ### Print Body of HTML doc ############################################################### print <<__HTML__; __HTML__ $active_id{"login"} = ""; $active_id{"create"} = ""; $active_id{"register"} = ""; $active_id{"verify"} = ""; $active_id{"pay"} = ""; #ADDED this portion to show logout feature. my $email = param('email'); my $pw = param('pw'); if(!(defined($email))){ $email = ""; $pw = ""; } my ($login, $failed_login, $admin) = print_reg_admin2($email, $pw, $org_id, "NA", "NA", "NA"); #my $session_id = check_reg_login($email, "$pw"); #print "SESSION ID: $session_id
\n"; #print_top($session_id); #print_right_border($org_id); #print_menu($org_id); #print_reg_info(); #print_reg_admin($session_id); print " \n"; print <<__HTML__; __HTML__ print "\n"; } ################################################################ ### Check to see if the user is logged in ################################################################ sub check_valid_user_reg_admin{ my $user = shift; my $pass = shift; my $org_id = shift; my $league_id = shift; my $info_id = shift; my $page = shift; my $success = 0; my $login_success = 0; my $session_id = get_cookie(); my $return_hash; $return_hash{"LOGIN_SUCCESS"} = 0; my $dbh = get_dbh(); #print "\n"; ################################################################ # Check to see if there is a valid cookie ################################################################ if($session_id eq ""){ #print "\n"; #print "\n"; ################################################################ # If not a valid cookie, check the to see if the user/pass # combination is correct ################################################################ if(($user ne "") && ($pass ne "")){ $query = "SELECT * FROM `Account_Info` WHERE (`Login` = '$user' OR `email` = '$user') AND `Password` = '$pass'"; #print "\n"; $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Login, \$Password, \$email, \$League_ID, \$Last_Access, \$Last_Access_ID, \$Firstname, \$Lastname, \$Title, \$Home_Phone, \$Work_Phone, \$Zip_Code, \$Token); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. It also checks to see that they are # logging into the correct league. # League 0 is all leagues. ################################################################ while($sth->fetch()) { $return_hash{"LOGIN_SUCCESS"} = 1; $return_hash{"EMAIL"} = $email; $return_hash{"LOGIN_ID"} = $Key; $return_hash{"LOGIN"} = $Login; $return_hash{"FIRSTNAME"} = $Firstname; $return_hash{"LASTNAME"} = $Lastname; $return_hash{"TITLE"} = $Title; $return_hash{"HOMEPHONE"} = $Home_Phone; $return_hash{"WORKPHONE"} = $Work_Phone; $return_hash{"ZIPCODE"} = $Zip_Code; $test_hash{"ONE"} = 1; } ################################################################ # Login failed because incorrect Login or password ################################################################ if($return_hash{"LOGIN_SUCCESS"} == 0){ $return_hash{"LOGIN_SUCCESS"} = -1; $session_id = ""; #print "\n"; }else{ $current_date = get_date_time(); $session_id = generate_random_string(15); $update = "UPDATE `Account_Info` SET `Last_Access`='$current_date', `Last_Access_ID`='$session_id' WHERE `Key` = $Key;"; #print "QUERY: $update
\n"; $sth = $dbh->prepare($update); $sth->execute(); print <<__HTML__; __HTML__ } }else{ ################################################################ # Login failed because no Login or password # Could be first time loggin in. ################################################################ $session_id = ""; } }else{ #print "\n"; ################################################################ # Query DB to verify Session ################################################################ $query = "SELECT * FROM `Account_Info` WHERE `Last_Access_ID` = '$session_id'"; $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Login, \$Password, \$email, \$League_ID, \$Last_Access, \$Last_Access_ID, \$Firstname, \$Lastname, \$Title, \$Home_Phone, \$Work_Phone, \$Mobile_Phone, \$Zip_Code, \$Token); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. It also checks to see that they are # logging into the correct league. # League 0 is all leagues. ################################################################ while($sth->fetch()) { $return_hash{"LOGIN_SUCCESS"} = 1; $return_hash{"EMAIL"} = $email; $return_hash{"LOGIN_ID"} = $Key; $return_hash{"FIRSTNAME"} = $Firstname; $return_hash{"LASTNAME"} = $Lastname; $return_hash{"TITLE"} = $Title; $return_hash{"HOMEPHONE"} = $Home_Phone; $return_hash{"WORKPHONE"} = $Work_Phone; $return_hash{"ZIPCODE"} = $Zip_Code; } #print "\n"; ################################################################ # If we get to this point. The cookie is invalid at least for # this league. ################################################################ if($return_hash{"LOGIN_SUCCESS"} == 0){ #print "

Your Session has expired,
Please login again.
\n"; print "\n"; $session_id = ""; }else{ ################################################################ # Update DB to keep session active ################################################################ $current_date = get_date_time(); $update = "UPDATE `Account_Info` SET `Last_Access`='$current_date' WHERE `Key` = $Key;"; ##print "QUERY: $update
\n"; $sth = $dbh->prepare($update); $sth->execute(); ################################################################ # Update Cookie to keep session active ################################################################ print <<__HTML__; __HTML__ } } ################################################################ # Close DB connection ################################################################ $sth->finish(); # disconnect from database $dbh->disconnect; #print "\n"; #foreach $key (keys %return_hash){ # print "\n"; #} $return_hash{"SESSION_ID"} = $session_id; # $return_hash{"TEST"} = "TEST"; return %return_hash; } sub print_reg_admin2{ my $user = shift; my $pass = shift; my $org_id = shift; my $league_id = shift; my $info_id = shift; my $page = shift; my $access_level = 0; my $admin = 1; my $login = 1; my $failed_login = 0; %valid_user = check_valid_user_reg_admin($user,$pass,$org_id,$league_id,$info_id,$page); if($valid_user{"LOGIN_SUCCESS"} == 1){ ################################## # Check valid user access ################################## $access_level = check_permissions_reg($valid_user{"LOGIN_ID"}, $org_id, $league_id, $info_id, $page); $login = 0; ################################## # if they are trying for a coach # or admin page, check verify permssions. ################################## #print "\n"; if($admin == 1){ if(!($access_level >=2)){ #print "\n"; $admin = 0; } } }elsif($valid_user{"LOGIN_SUCCESS"} == -1){ $failed_login = 1; $login = 1; }else{ ################################## # if not valid user (ie. not logged in) # check if it was attempting a admin # or coach ################################## if(($coach == 1)||($admin == 1)){ #print "\n"; #$coach = 0; #$admin = 0; $login = 1; } } if($admin == 1){$session_id = "1234";}else{$session_id = "";} #admin = 1 prints logout, admin != 1 prints log in. if($access_level >=2){ print_top_admin($session_id); }else{ print_top_admin(""); } if($action eq "adminlogin"){ ##### Log in to verify USER Account information if($failed_login == 1){ print "\n"; print_admin_login("Your username or password was incorrect."); }elsif($admin == 0){ print "\n"; print_admin_login("You do not have access to this page."); }else{ #print_show_reg($org_id); print_show_reg($org_id); } }elsif($action eq "logout"){ print "\n"; print_admin_login("You have successfully logged out."); }elsif($action eq "admin_create_account"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ if(check_for_account($newemail)== 0){ ##### Verify Email Account admin_print_create_account(); }else{ $msg = ""; ########################################### # BEGIN New method send user to register ########################################### if(defined($newemail)){ my %user_info = get_account_info_by_email($newemail); my $user_key = $user_info{"KEY"}; print_register_programs($user_key); }else{ admin_print_create_user($msg); } ########################################### # END New method send user to register ########################################### ########################################### #OLD Method. Send message and ask for different account ########################################### #$msg = ""; #if(defined($newemail)){ #$msg = "Email is already in use, please try another."; #} #admin_print_create_user($msg); ########################################### # End Old method ########################################### } } }elsif($action eq 'enrollment_report'){ #### Add ability to Accept/Decline users if($failed_login == 1){ print "\n"; print_admin_login("Your username or password was incorrect."); }elsif($admin == 0){ print "\n"; print_admin_login("You do not have access to this page."); }else{ #print_show_reg($org_id); print_show_reg_enrollment_report($org_id); } }elsif($action eq 'reg_comm'){ #### Add ability to Accept/Decline users if($failed_login == 1){ print "\n"; print_admin_login("Your username or password was incorrect."); }elsif($admin == 0){ print "\n"; print_admin_login("You do not have access to this page."); }else{ #print_show_reg($org_id); print_my_communications_history($reg_year); } }elsif($action eq "admin_createaccount"){ ##### Create New USER Account, Get information to create new PLAYER Account if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ $user_email = get_param('email'); if(check_for_account($user_email)== 0){ ##### Verify Email Account $user_key = admin_createaccount(); } admin_print_verify_account_info($user_email); #print_register_programs($user_key); } }elsif($action eq "admin_modify"){ ##### Get Information to Update USER Account if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ $user_email = param('email'); admin_print_update_account($user_email); } }elsif($action eq "admin_modifyaccount"){ ##### Modify USER Account, Verify Information if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ $email = admin_update_account(); admin_print_verify_account_info($email); } }elsif($action eq "register"){ ##### After a USER logs in, Get information to create new PLAYER Account if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print " \n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); if((!(defined($user_key))) || ($user_key eq "")){ $email = param('email'); my %user_info = get_account_info_by_email($email); $user_key = $user_info{"KEY"}; } print_register_programs($user_key); } }elsif($action eq "pay_by_check"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_pay_by_check(); } }elsif($action eq "pay_by_check_complete"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_pay_partial_complete(); } }elsif($action eq "admin_account"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ #print_show_reg($org_id); admin_print_create_user(); } }elsif($action eq "createaplayerccount"){ ##### Create PLAYER account, Verify Information if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $new_player_id = create_new_player($org_id, $reg_year); remove_all_multiplayer_discounts_after_remove_player($user_key); add_multi_player_discount_all_players($user_key); #check_for_multiplayer_discounts($user_key, $new_player_id); print_verify_register_programs($new_player_id); } }elsif($action eq "modify_player"){ #### Get Information to Modify PLAYER if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_modify_player(); } }elsif($action eq "updateplayerccount"){ ###### Modify PLAYER Account, Verify Information if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $player_id = param('playerkey'); my $user_key = param('userkey'); my $first_name = get_param("fname"); my $last_name = get_param("lname"); update_player_name($player_id, $first_name, $last_name); get_player_params_and_update_database($org_id, $reg_year, $player_id, $user_key); print_verify_register_programs($player_id); } }elsif($action eq "partial"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_pay_partial(); } }elsif($action eq "pay"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_pay(); } }elsif($action eq "verify_partial"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_verify_pay_partial(); } }elsif($action eq "remove_player"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); remove_player($player_key); #verify_multiplayer_discounts_after_remove_player($user_key, $player_key); remove_all_multiplayer_discounts_after_remove_player($user_key); add_multi_player_discount_all_players($user_key); print_register_programs($user_key); } }elsif($action eq "admin_manual_player_update"){ ### Enrollment Player Update if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); print_admin_manual_modify_player($player_key); } }elsif($action eq "admin_manual_player_update2"){ ### Enrollment Player Update - actually make update if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); my $first_name = get_param("fname"); my $last_name = get_param("lname"); update_player_name($player_key, $first_name, $last_name); get_player_params_and_update_database($org_id, $reg_year, $player_key, $user_key); print_show_reg($org_id); } }elsif($action eq "admin_manual_player_remove"){ ### Enrollment Player Update - actually make update if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ #my $user_key = param('userkey'); # Not sure if account id and user key is different my $player_key = param('player_id'); #my $account_id = get_account_id_by_player_key($player_key); my $user_key = get_account_id_by_player_key($player_key); remove_player($player_key); remove_all_multiplayer_discounts_after_remove_player($user_key); add_multi_player_discount_all_players($user_key); print_show_reg($org_id); } }elsif($action eq "admin_manual_player_update_paid"){ ### Enrollment Player Update if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); print_admin_manual_modify_player_paid($player_key); } }elsif($action eq "admin_manual_status_update"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); print_admin_manual_status_update($player_key); } }elsif($action eq "admin_manual_status_update2"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); my $status = param('status_update'); #my $team_reg_value = get_param('REG38'); #dev #my $uniform_reg_id = get_param('REG37'); #dev my $team_reg_value = get_param('REG1117'); my $uniform_reg_id = get_param('REG1116'); my %status_hash = get_status_hash($org_id, $reg_year); update_player_status($user_key, $player_key, $status); #update_database_for_hidden_fields($org_id, $reg_year, $player_key, $user_key, 12, 37, $uniform_reg_id); #dev #update_database_for_hidden_fields($org_id, $reg_year, $player_key, $user_key, 13, 38, $team_reg_value); #dev update_database_for_hidden_fields($org_id, $reg_year, $player_key, $user_key, 12, 1116, $uniform_reg_id); update_database_for_hidden_fields($org_id, $reg_year, $player_key, $user_key, 13, 1117, $team_reg_value); #print "STATUS: $status
\n"; if($status_hash{$status}{"ACCEPTED_STATE"} == -1){ remove_player($player_key); remove_all_multiplayer_discounts_after_remove_player($user_key); add_multi_player_discount_all_players($user_key); } print_show_reg_enrollment_report($org_id); } }elsif($action eq "admin_apply_normal_reg_filter"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_show_reg($org_id); } }elsif($action eq "admin_apply_enrollment_filter"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_show_reg_enrollment_report($org_id); } } elsif($action eq "admin_manual_assignment_update"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); print_admin_manual_assignment_update($player_key); } }elsif($action eq "admin_manual_assignment_update2"){ if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); my $league_assign = param('league_assign'); my $team_assign = param('team_assign'); update_player_assignment($user_key, $player_key, $league_assign, $team_assign); print_show_reg_enrollment_report($org_id); } }elsif($action eq "admin_manual_player_update_paid2"){ ### Enrollment Player Update - actually make update if($failed_login == 1){ print "\n"; print_admin_login(""); }elsif($admin == 0){ print "\n"; print_admin_login(""); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ my $user_key = param('userkey'); my $player_key = param('playerkey'); my $first_name = get_param("fname"); my $last_name = get_param("lname"); my $amount = get_param('amount_to_update'); my $check_notes = get_param('check_notes'); my $tx_amount = 0 - $amount; # we make this negative so that it comes off the balance insert_transaction($player_key, $tx_amount, $check_notes); update_player_paid($player_key, $amount); #update_player_name($player_key, $first_name, $last_name); #get_player_params_and_update_database($org_id, $reg_year, $player_key, $user_key); print_show_reg($org_id); } }else{ if($failed_login == 1){ print "\n"; print_admin_login("Your username or password was incorrect."); }elsif($admin == 0){ print "\n"; print_admin_login("You do not have access to this page."); }elsif($login == 1){ print "\n"; print_admin_login(""); }else{ print_admin_home("", $access_level); } } return $login, $failed_login, $admin; } ################################################################ ### Update player in db ################################################################ sub insert_transaction{ my $player_key = shift; my $amount = shift; my $check_notes = 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 ('', '$account_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; } sub update_player_paid{ my $player_key = shift; my $amount = shift; my $query = "UPDATE Reg_Player_Link SET `Paid`=`Paid`+ " . $amount . " WHERE `Key` = '$player_key';"; #print "$query
\n"; my $dbh = get_dbh(); my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; } ########################################### # Modify player info on main registration ########################################### sub print_admin_manual_assignment_update{ my $player_key = param('player_id'); my %mod_player_info = get_player_info_by_key($player_key); my $user_key = $mod_player_info{"ACCOUNT_ID"}; my %user_info = get_account_info($user_key); my %leagues = get_leagues_by_org($org_id); my %status_hash = get_status_hash($org_id, $reg_year); my $player_status = $status_hash{$mod_player_info{"PLAYER_CONFIRMED"}}{"DESC"}; my $player_pay_update_table = print_modify_player_paid($player_key, $user_key); my $account_table = get_account_table_admin_box($user_key); my ($user_table, $player_num) = get_player_table_old($user_key); my $player_league_assigned = "Unassigned"; my $player_team_assigned = "Unassigned"; if($mod_player_info{"ASSIGNED_LEAGUE"} != 0){ $player_league_assigned = get_league_name($mod_player_info{"ASSIGNED_LEAGUE"}); } if($mod_player_info{"ASSIGNED_TEAM"} != 0){ $player_team_assigned = get_team_name($mod_player_info{"ASSIGNED_TEAM"}); } $active_id{"register"} = "id=current"; print_no_steps(); ####################################### # Get all teams and leagues ####################################### my %leagues_and_teams = get_leagues_and_teams_by_org($org_id); ####################################### # Create League assignment pulldown ####################################### my $league_assignment_update = "\n"; $team_assignment_update .= "\n"; my $dynamic_team_drop_down_js = "var menu_options = new Array();\n"; $dynamic_team_drop_down_js .= "menu_options[0] = new Array();\n"; $dynamic_team_drop_down_js .= "menu_options[0][0] = \"Unassigned\";\n"; my $dynamic_team_id_drop_down_js = "var menu_id_options = new Array();\n"; $dynamic_team_id_drop_down_js .= "menu_id_options[0] = new Array();\n"; $dynamic_team_id_drop_down_js .= "menu_id_options[0][0] = 0;\n"; my $dynamic_league_map = "var league_map = new Array();\n"; $dynamic_league_map .= "league_map[0] = 0;\n"; my $league_count = 1; ######################################## # Loop through Leagues and independent teams ######################################## foreach my $league (sort {$a cmp $b} keys %leagues_and_teams){ my $team_count = 1; my $league_selected = ""; $dynamic_league_map .= "league_map[" . $leagues_and_teams{$league}{"LEAGUE_ID"} . "] = $league_count;\n"; $dynamic_team_drop_down_js .= "menu_options[$league_count] = new Array();\n"; $dynamic_team_drop_down_js .= "menu_options[$league_count][0] = \"Unassigned\";\n"; $dynamic_team_id_drop_down_js .= "menu_id_options[$league_count] = new Array();\n"; if($mod_player_info{"ASSIGNED_LEAGUE"} == $leagues_and_teams{$league}{"LEAGUE_ID"}){ $league_selected = "SELECTED"; } $league_assignment_update .= "\n"; ######################################## # Loop through teams assigned to leagues and independent teams # Create javascript and current select menu ######################################## foreach my $team (sort {$a cmp $b} keys %{$leagues_and_teams{$league}}){ my $team_selected = ""; #print "LEAGUE:TEAM: $league:$team:$leagues_and_teams{$league}{$team}
\n"; ######################################## # Sincle LEAGUE_IDs are also stored in hash # make sure we are not lookin at them ######################################## if($team ne "LEAGUE_ID"){ $dynamic_team_drop_down_js .= "menu_options[$league_count][$team_count] = \"$team\";\n"; $dynamic_team_id_drop_down_js .= "menu_id_options[$league_count][$team_count] = $leagues_and_teams{$league}{$team} ;\n"; $team_count++; ######################################## # Check to see if a league is selected # then populate options for that league ######################################## if($league_selected eq "SELECTED"){ if($mod_player_info{"ASSIGNED_TEAM"} == $leagues_and_teams{$league}{$team}){ $team_selected = "SELECTED"; } $team_assignment_update .= "\n"; } } } $league_count++; #if($mod_player_info{"ASSIGNED_LEAGUE"} == $leagues{$league}){ #$this_selected = "SELECTED"; #} #$league_assignment_update .= "\n"; } $team_assignment_update .= "\n"; $league_assignment_update .= "\n"; my $html = <<__HTML__;
  Update Player Assignments

$account_table

Player Status
NameLeague AssignmentTeam Assignment
$mod_player_info{"FIRSTNAME"} $mod_player_info{"LASTNAME"} $player_league_assigned $player_team_assigned
Update Status $league_assignment_update $team_assignment_update
  

__HTML__ print $html; } ########################################### # Modify player info on main registration ########################################### sub print_admin_manual_status_update{ my $player_key = param('player_id'); my %mod_player_info = get_player_info_by_key($player_key); my $user_key = $mod_player_info{"ACCOUNT_ID"}; my %user_info = get_account_info($user_key); my %filters = get_filter_values(); my %status_hash = get_status_hash($org_id, $reg_year); my $player_status = $status_hash{$mod_player_info{"PLAYER_CONFIRMED"}}{"DESC"}; my $player_pay_update_table = print_modify_player_paid($player_key, $user_key); my $account_table = get_account_table_admin_box($user_key); my ($user_table, $player_num) = get_player_table_old($user_key); #my $team_reg_id = "REG38"; #dev #my $uniform_reg_id = "REG37"; #dev #my $team_key = 510; #2010 plymouth Assigned team Hidden Value #my $uniform_key = 509; #2010 plymouth Hidden Uniform Number my $team_key = 1117; #2010 plymouth Assigned team Hidden Value my $uniform_key = 1116; #2010 plymouth Hidden Uniform Number my $team_reg_id = "REG" . "$team_key"; my $uniform_reg_id = "REG" . "$uniform_key"; #my $player_team = get_cell_value(13, 38, $player_key); #dev #my $player_uniform = get_cell_value(12, 37, $player_key); #dev my $player_team = get_cell_value(13, $team_key, $player_key); my $player_uniform = get_cell_value(12, $uniform_key, $player_key); if($player_team eq ""){ $player_team = "Unassigned"; } if($player_uniform eq ""){ $player_uniform = "Unassigned"; } my $accepted_value = 3; my $status_js = "var status_states = new Array();\n"; foreach my $state_id (sort {$a<=>$b} keys %status_hash){ my $accepted_state = $status_hash{$state_id}{"ACCEPTED_STATE"}; $status_js .= "status_states[$state_id] = $accepted_state;\n"; } my $disabled = "DISABLED"; if($mod_player_info{"PLAYER_CONFIRMED"} == $accepted_value){ $disabled = ""; } #my $player_team_update = get_reg_cell_with_update_hidden(13, 38, $team_reg_id, $player_key, 0, $disabled); #dev #my $player_uniform_update = get_reg_cell_with_update_hidden(12, 37, $uniform_reg_id, $player_key, 10, $disabled); #dev my $player_team_update = get_reg_cell_with_update_hidden(13, $team_key, $team_reg_id, $player_key, 0, $disabled); my $player_uniform_update = get_reg_cell_with_update_hidden(12, $uniform_key, $uniform_reg_id, $player_key, 10, $disabled); $active_id{"register"} = "id=current"; print_no_steps(); my $status_update = "\n"; my $filter1_field = $filters{'1'}{"FILTER_FIELD"}; my $filter1_value = $filters{'1'}{"FILTER_VALUE"}; my $hidden_filters = ""; $hidden_filters .= ""; ##### This is JS dev below # var teamEL = document.getElementById('REG38'); # dev below # var uniformEL = document.getElementById('REG37'); # dev below # # var teamEL = document.getElementById('REG38'); # var uniformEL = document.getElementById('REG37'); my $html = <<__HTML__;
  Update Player Status

$account_table

$hidden_filters
Player Status
Name Status Team Assignment Uniform Number
$mod_player_info{"FIRSTNAME"} $mod_player_info{"LASTNAME"} $player_status $player_team $player_uniform
Update Status $status_update $player_team_update $player_uniform_update
  

__HTML__ print $html; } ########################################### # Modify player info on main registration ########################################### sub print_admin_manual_modify_player_paid{ my $player_key = param('player_id'); my %mod_player_info = get_player_info_by_key($player_key); my $user_key = $mod_player_info{"ACCOUNT_ID"}; my %user_info = get_account_info($user_key); my $player_pay_update_table = print_modify_player_paid($player_key, $user_key); my $account_table = get_account_table($user_key); my ($user_table, $player_num) = get_player_table_old($user_key); my %filters = get_filter_values(); my $filter1_field = $filters{'1'}{"FILTER_FIELD"}; my $filter1_value = $filters{'1'}{"FILTER_VALUE"}; my $hidden_filters = ""; $hidden_filters .= ""; $active_id{"register"} = "id=current"; print_no_steps(); my $html = <<__HTML__;
Update Player Payment
$account_table
$hidden_filters
$player_pay_update_table
__HTML__ print $html; } ########################################### # Modify player info on admin registration ########################################### sub print_modify_player_paid{ my $initial_player_key = shift; my $user_key = shift; my %user_info = get_account_info($user_key); my %player_info = (); my $player_header1 = "cal_events3"; my $player_header2 = "cal_events2"; my $player_header = $player_header1; my $user_header = "date_header"; my $paypal_header_info = get_player_header6(); my $all_transction_head = "Transaction Information for Account Owner
$user_info{\"FIRSTNAME\"} $user_info{\"LASTNAME\"}\n"; my $table_header = "\n"; my %tmp_player_info = get_player_info($user_key); my $paid = 0; my $html = ""; my $num_players = 0; my $user_table = get_checkout_header("Register Payment for Player"); my $all_user_table = get_checkout_header("Payment Information for for Account Owner
$user_info{\"FIRSTNAME\"} $user_info{\"LASTNAME\"}"); ######################################## # Loop through player information to generate tables ######################################## foreach my $player_order (sort {$a <=> $b}(keys %tmp_player_info)) { $player_key = $tmp_player_info{$player_order}{"KEY"}; $player_info{$player_key}{"ULASTNAME"} = $users{$user_key}{"LASTNAME"}; $player_info{$player_key}{"UFIRSTNAME"} = $users{$user_key}{"FIRSTNAME"}; $player_info{$player_key}{"UHOMEPHONE"} = $users{$user_key}{"HOMEPHONE"}; $player_info{$player_key}{"UEMAIL"} = $users{$user_key}{"EMAIL"}; #($total, %adjustment_info) = get_adjustment_info($player_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. ############################################ if($player_header eq $player_header1){ $player_header = $player_header2; }else{ $player_header = $player_header1; } my ($player_row, %checkout_hash) = get_checkout_row_for_player_and_total_due_and_pay_pal($player_key, $tmp_player_info{$player_order}{"FIRSTNAME"}, $tmp_player_info{$player_order}{"LASTNAME"}, $player_header); my $amount_due = $checkout_hash{"TOTAL_DUE"}; my $paypal_string = $checkout_hash{"PAYPAL_STRING"}; my $total_paid = $checkout_hash{"TOTAL_PAID"}; ########################################### # If it is the initial player key, this means that this is the user they are # updating. Generate the Register Payment player for them ########################################### if($initial_player_key == $player_key){ ############# Run this again to insure the correct style for the current player my ($player_row, %checkout_hash) = get_checkout_row_for_player_and_total_due_and_pay_pal($player_key, $tmp_player_info{$player_order}{"FIRSTNAME"}, $tmp_player_info{$player_order}{"LASTNAME"}, $player_header2); $user_table .= $player_row; $max_amount_due = $amount_due; } $all_user_table .= $player_row; ##########################################################3 # Calculate amount total, paid and due ########################################################### $num_players++; $amount_paid = $total_paid; #($tmp_pay_pal_info, $player_amount) = get_paypal_info($tmp_player_info{$player_order}{"LASTNAME"}, $tmp_player_info{$player_order}{"FIRSTNAME"}, $player_key); ($tmp_transaction_info, $player_amount2) = get_transaction_info($tmp_player_info{$player_order}{"LASTNAME"}, $tmp_player_info{$player_order}{"FIRSTNAME"}, $player_key); #($tmp_adjustment_info, $player_amount3) = get_adjustment_info($tmp_player_info{$player_order}{"LASTNAME"}, $tmp_player_info{$player_order}{"FIRSTNAME"}, $player_key); $pay_pal_info = $pay_pal_info . $tmp_pay_pal_info; $transaction_info = $transaction_info . $tmp_transaction_info; } my $jscript = get_register_payment_jscript(); ######################################## # This is the register payment table ######################################## my $payment_update_form = <<__HTML__; $user_table
Enter Payment Received or Manual Adjustment for this Player \$
Enter Check No. or Notes
  
__HTML__ $all_user_table .= ""; my $transaction_table = $table_header . $all_transction_head . $paypal_header_info . $transaction_info . ""; $return_html = $jscript . "
\n" . $payment_update_form . $transaction_table . "
" . $all_user_table . "
\n" . "

"; return $return_html; } ############################################# # This just returns some javascript required for the register payment ############################################# sub get_register_payment_jscript{ my $jscript = <<__JSCRIPT__; __JSCRIPT__ } sub get_player_header6{ $player_header3 = "admin_header"; my $player_header .= "Name \n"; $player_header .= "Amount \n"; $player_header .= "Notes \n"; $player_header .= "Date\n"; $player_header .= "Changed By \n"; return $player_header; } sub get_player_header7{ $player_header3 = "cal_events_head"; my $player_header .= "Player Last Name \n"; $player_header .= "Player First Name \n"; $player_header .= "Fees \n"; $player_header .= "Total \n"; $player_header .= "Paid \n"; $player_header .= "Due \n"; return $player_header; } sub get_paypal_info{ my $last_name = shift; my $first_name = shift; my $player_key = shift; my $return_string = ""; my $amount = 0; $player_header1 = "cal_events3"; $player_header2 = "cal_events2"; $user_header = "date_header"; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Amount`, `PP_Transaction_ID`, `Date` FROM `Reg_Paypal` WHERE `Player_ID` = '$player_key' AND `Processed` = '1';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Amount, \$PP_Transaction_ID, \$Date); while($sth->fetch()) { if($player_header eq $player_header1){ $player_header = $player_header2; }else{ $player_header = $player_header1; } $Amount = sprintf("%.2f", $Amount); $return_string .= "$last_name$first_name\$$Amount$PP_Transaction_ID$DatePayPal"; $return_amount = $return_amount + $amount; } # disconnect from database $sth->finish(); $dbh->disconnect; #print "RP: $return_password
\n"; return $return_string, $amount; } sub get_transaction_info{ my $last_name = shift; my $first_name = shift; my $player_key = shift; my $return_string = ""; my $amount = 0; $player_header1 = "cal_events3"; $player_header2 = "cal_events2"; $user_header = "date_header"; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT a.`Amount`, a.`Check_ID`, a.`Date`, b.`Login` FROM `Reg_All_Transaction` a, `Account_Info` b WHERE a.`Player_ID` = '$player_key' AND b.`Key` = a.`Update_Account_ID` ORDER BY a.`Date`;"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Amount, \$Check_ID, \$Date, \$Login); while($sth->fetch()) { if($player_header eq $player_header1){ $player_header = $player_header2; }else{ $player_header = $player_header1; } $Amount = sprintf("%.2f", $Amount); $return_string .= "$first_name $last_name\$$Amount$Check_ID$Date$Login"; $return_amount = $return_amount + $amount; } # disconnect from database $sth->finish(); $dbh->disconnect; #print "RP: $return_password
\n"; return $return_string, $amount; } ########################################### # Modify player info on main registration ########################################### sub print_admin_manual_modify_player{ my $player_key = param('player_id'); my %mod_player_info = get_player_info_by_key($player_key); my $user_key = $mod_player_info{"ACCOUNT_ID"}; my %user_info = get_account_info($user_key); my $account_table = get_account_table($user_key); my ($user_table, $player_num) = get_player_table_old($user_key); #################################################################### # Get filter fields and store as hidden fields #################################################################### my %filters = get_filter_values(); my $filter1_field = $filters{'1'}{"FILTER_FIELD"}; my $filter1_value = $filters{'1'}{"FILTER_VALUE"}; my $hidden_filters = ""; $hidden_filters .= ""; $active_id{"register"} = "id=current"; print_no_steps(); #print "
\n"; %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__;
Update Player Registration
    * Required Fields

$account_table
$hidden_filters
$auto_reg_form
Player Information
Player First Name*
Player Last Name*


* Required Fields
__HTML__ print $html; } ################################################################ ### Prints the top title bar ################################################################ sub print_top_admin{ $session_id = shift; if($session_id ne ""){ $access_level =1; } print <<__HTML__;
__HTML__ print "
\n"; if($access_level == 1){ #print "Welcome, $valid_user{\"FIRSTNAME\"}\n"; ################################# ## If Admin ################################# if($access_level >= 3){ print "   Control Panel\n"; } if($access_level >= 1){ #print "   My Hometeamz\n"; #print "   Create Account"; print "   Registration Menu"; print "   Logout"; } }else{ #print "Login"; } print <<__HTML__;
 

$site_info{"site_banner_text"}


__HTML__ } sub get_transactions{ my $transaction_id = shift; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB for tranasctions ################################################################ my $query = "SELECT `Key`, `Player_ID`, `Amount`, `Processed` FROM `Reg_Paypal` WHERE `Transaction_ID` = '$transaction_id'"; #my $query = "SELECT `Key`, `Player_ID`, `Amount` FROM `Reg_Paypal` WHERE `Transaction_ID` = '$transaction_id' AND `Processed` = '1'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key, \$Player_ID, \$Amount, \$Processed); while($sth->fetch()) { $return_hash{$Player_ID}{"AMOUNT"} = $Amount; $return_hash{$Player_ID}{"PROCESSED"} = $Processed; } $sth->finish(); $dbh->disconnect; return %return_hash; } sub print_show_purchase_invalid{ #my $transaction_id = shift; #my %transactions = get_transactions($transaction_id); #my %users = get_users_by_org($org_id); #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 %division_selected = get_division_data(); #print "

\n"; $html = "
"; $html .= "
Invalid Transaction
You have tried to view a transaction you do not have permissions for or have been logged out of your account.
Click HERE to return to the registration page.

\n"; $html .= "
\n"; print $html; } sub admin_print_pay_partial_complete{ #print "

\n"; $active_id{"complete"} = "id=current"; print_steps(); $html = "
"; $html .= "
Step 6 : Order Complete
Thank-you for registering for the Lakes Youth Athletic Association 2008 Season.\n

Your order is complete. If you require any assistance with the online registration process, or have any general questions regarding LYAA registration, please contact the board by emailing board\@lyaa.org, or leaving a message at (847) 604-0270.


\n"; $html .= "\n"; $html .= "
\n"; print $html; } sub print_thanks{ $transaction_id = shift; print_show_purchase($transaction_id); print "
\n"; print <<__HTML__; __HTML__ print "\n"; } sub print_reg_admin{ $session_id = shift; if($action eq "adminlogin"){ ##### Log in to verify USER Account information if($session_id eq ""){ print_admin_login("Your username or password was incorrect."); }else{ print_show_reg($org_id); } }else{ if($session_id eq ""){ print_admin_login(); }else{ print_show_reg($org_id); } } print "
\n"; print <<__HTML__; __HTML__ print "\n"; } sub get_player_header8_tab{ my $player_header .= '"Player Last Name"' . "\t"; $player_header .= '"Player First Name"' . "\t"; $player_header .= '"Registration Date"' . "\t"; $player_header .= '"Player DOB"' . "\t"; $player_header .= '"Player Gender"' . "\t"; $player_header .= '"Player School_Name"' . "\t"; $player_header .= '"Player Grade"' . "\t"; $player_header .= '"Emergency Contact Name"' . "\t"; $player_header .= '"Emergency Contact Phone1"' . "\t"; $player_header .= '"Emergency Contact Phone2"' . "\t"; $player_header .= '"Emergency Contact Relationship"' . "\t"; $player_header .= '"Guardian1 Contact Phone1"' . "\t"; $player_header .= '"Guardian1 Contact Phone2"' . "\t"; $player_header .= '"Guardian1 Name"' . "\t"; $player_header .= '"Guardian1 Relationship"' . "\t"; $player_header .= '"Guardian2 Contact Phone1"' . "\t"; $player_header .= '"Guardian2 Contact Phone2"' . "\t"; $player_header .= '"Guardian2 Name"' . "\t"; $player_header .= '"Guardian2 Relationship"' . "\t"; $player_header .= '"Preferred Doc Name"' . "\t"; $player_header .= '"Preferred Doc Number"' . "\t"; $player_header .= '"Preferred Dentist Name"' . "\t"; $player_header .= '"Preferred Dentist Number"' . "\t"; $player_header .= '"Preferred Hospital"' . "\t"; $player_header .= '"Insurance Carrier"' . "\t"; $player_header .= '"Policy Number"' . "\t"; $player_header .= '"Medical History"' . "\t"; $player_header .= '"Returning Player"' . "\t"; $player_header .= '"Paid"' . "\t"; $player_header .= '"Fee"' . "\t"; $player_header .= '"Fundraiser"' . "\t"; $player_header .= '"Adjustment"' . "\t"; $player_header .= '"Late Fee"' . "\t"; $player_header .= '"Payment Information"' . "\t"; $player_header .= '"Medical Consent Choice"' . "\t"; $player_header .= '"Medical Consent Notes"' . "\t"; $player_header .= '"Play Up"' . "\t"; $player_header .= '"Account First Name"' . "\t"; $player_header .= '"Account Last Name"' . "\t"; $player_header .= '"Account Email"' . "\t"; $player_header .= '"Account Address1"' . "\t"; $player_header .= '"Account Address2"' . "\t"; $player_header .= '"Account City"' . "\t"; $player_header .= '"Account State"' . "\t"; $player_header .= '"Account Zip"' . "\t"; $player_header .= '"Account Phone"' . "\t"; $player_header .= '"Account Mphone"'; return $player_header; } sub get_player_header8_csv{ my $player_header .= '"Player Last Name",'; $player_header .= '"Player First Name",'; $player_header .= '"Registration Date",'; $player_header .= '"Player DOB",'; $player_header .= '"Player Gender",'; $player_header .= '"Player School_Name",'; $player_header .= '"Player Grade",'; $player_header .= '"Emergency Contact Name",'; $player_header .= '"Emergency Contact Phone1",'; $player_header .= '"Emergency Contact Phone2",'; $player_header .= '"Emergency Contact Relationship",'; $player_header .= '"Guardian1 Contact Phone1",'; $player_header .= '"Guardian1 Contact Phone2",'; $player_header .= '"Guardian1 Name",'; $player_header .= '"Guardian1 Relationship",'; $player_header .= '"Guardian2 Contact Phone1",'; $player_header .= '"Guardian2 Contact Phone2",'; $player_header .= '"Guardian2 Name",'; $player_header .= '"Guardian2 Relationship",'; $player_header .= '"Preferred Doc Name",'; $player_header .= '"Preferred Doc Number",'; $player_header .= '"Preferred Dentist Name",'; $player_header .= '"Preferred Dentist Number",'; $player_header .= '"Preferred Hospital",'; $player_header .= '"Insurance Carrier",'; $player_header .= '"Policy Number",'; $player_header .= '"Medical History",'; $player_header .= '"Returning Player",'; $player_header .= '"Paid",'; $player_header .= '"Fee",'; $player_header .= '"Fundraiser",'; $player_header .= '"Adjustment",'; $player_header .= '"Late Fee",'; $player_header .= '"Payment Information",'; $player_header .= '"Medical Consent Choice",'; $player_header .= '"Medical Consent Notes",'; $player_header .= '"Play Up",'; $player_header .= '"Account First Name",'; $player_header .= '"Account Last Name",'; $player_header .= '"Account Email",'; $player_header .= '"Account Address1",'; $player_header .= '"Account Address2",'; $player_header .= '"Account City",'; $player_header .= '"Account State",'; $player_header .= '"Account Zip",'; $player_header .= '"Account Phone",'; $player_header .= '"Account Mphone",'; return $player_header; } sub get_player_header_dynamic{ my $player_header3 = "cal_events_head"; my $player_header = "Edit Player \n"; $player_header .= "Remove Player \n"; $player_header .= "Total \n"; $player_header .= "Paid \n"; $player_header .= "Due \n"; my %column_headers = get_column_headers_report(); foreach $order (sort{$a <=> $b}keys %column_headers){ $player_header .= "$column_headers{$order}{\"TITLE\"} \n"; } return $player_header; } sub get_player_header_dynamic_enrollment{ my $flex_coach_accept = shift; my $flex_league_assign = shift; my $player_header3 = "cal_events_head"; my $player_header = ""; #$player_header .= "Pay Status \n"; #$player_header .= "Email \n"; #if($flex_coach_accept == 1){ # $player_header .= "Registration
Status \n"; #} #if($flex_league_assign == 1){ # $player_header .= "Assignment
Status \n"; # $player_header .= "Assigned
League \n"; # $player_header .= "Assigned
Team \n"; #} my %column_headers = get_column_headers_report_enrollment(); foreach $order (sort{$a <=> $b}keys %column_headers){ $player_header .= "$column_headers{$order}{\"TITLE\"} \n"; } return $player_header; } sub get_column_headers_report_enrollment{ #my $org_id = shift; #my $reg_year = shift; my %return_hash = (); my $dbh = get_dbh(); $return_hash{1}{"TABLE"} = "REG_DEFINITION"; #$return_hash{1}{"FIELD"} = "36"; # Dev #$return_hash{1}{"FIELD"} = "514"; # 2010 plymouth $return_hash{1}{"FIELD"} = "1121"; # 2011 plymouth $return_hash{1}{"TITLE"} = "Gender / Age Group"; $return_hash{2}{"TABLE"} = "PLAYER"; $return_hash{2}{"FIELD"} = "LASTNAME"; $return_hash{2}{"TITLE"} = "Player Lastname"; $return_hash{3}{"TABLE"} = "PLAYER"; $return_hash{3}{"FIELD"} = "FIRSTNAME"; $return_hash{3}{"TITLE"} = "Player Firstname"; $return_hash{4}{"TABLE"} = "PRE_DEFINED"; $return_hash{4}{"FIELD"} = "EMAIL"; $return_hash{4}{"TITLE"} = "Email"; $return_hash{5}{"TABLE"} = "PRE_DEFINED"; $return_hash{5}{"FIELD"} = "DISPLAY_STATUS"; #$return_hash{5}{"FIELD"} = "ASSIGN_STATUS"; $return_hash{5}{"TITLE"} = "Registration Status"; $return_hash{6}{"TABLE"} = "REG_DEFINITION"; #$return_hash{6}{"FIELD"} = "38"; # dev #$return_hash{6}{"FIELD"} = "510"; #2010 plymouth $return_hash{6}{"FIELD"} = "1117"; #2011 plymouth $return_hash{6}{"TITLE"} = "Assigned Team"; $return_hash{7}{"TABLE"} = "REG_DEFINITION"; #$return_hash{7}{"FIELD"} = "37"; #dev #$return_hash{7}{"FIELD"} = "509"; #2010 plymouth $return_hash{7}{"FIELD"} = "1116"; #2011 plymouth $return_hash{7}{"TITLE"} = "Uniform Number"; $return_hash{8}{"TABLE"} = "USER"; $return_hash{8}{"FIELD"} = "LASTNAME"; $return_hash{8}{"TITLE"} = "Account Lastname"; $return_hash{9}{"TABLE"} = "USER"; $return_hash{9}{"FIELD"} = "FIRSTNAME"; $return_hash{9}{"TITLE"} = "Account Firstname"; $return_hash{10}{"TABLE"} = "USER"; $return_hash{10}{"FIELD"} = "HOMEPHONE"; $return_hash{10}{"TITLE"} = "Home Phone"; $return_hash{11}{"TABLE"} = "PLAYER"; $return_hash{11}{"FIELD"} = "REG_DATE"; $return_hash{11}{"TITLE"} = "Registration Date"; #$return_hash{6}{"TABLE"} = "REG_DEFINITION"; #$return_hash{6}{"FIELD"} = "7"; #$return_hash{6}{"TITLE"} = "DOB"; #$return_hash{7}{"TABLE"} = "REG_DEFINITION"; #$return_hash{7}{"FIELD"} = "6"; #$return_hash{7}{"TITLE"} = "Gender"; return %return_hash; } sub get_column_headers_report{ #my $org_id = shift; #my $reg_year = shift; my %return_hash = (); my $dbh = get_dbh(); if($org_id == 167){ $return_hash{1}{"TABLE"} = "USER"; $return_hash{1}{"FIELD"} = "LASTNAME"; $return_hash{1}{"TITLE"} = "Account Lastname"; $return_hash{2}{"TABLE"} = "USER"; $return_hash{2}{"FIELD"} = "FIRSTNAME"; $return_hash{2}{"TITLE"} = "Account Firstname"; $return_hash{3}{"TABLE"} = "USER"; $return_hash{3}{"FIELD"} = "HOMEPHONE"; $return_hash{3}{"TITLE"} = "Home Phone"; $return_hash{4}{"TABLE"} = "PLAYER"; $return_hash{4}{"FIELD"} = "LASTNAME"; $return_hash{4}{"TITLE"} = "Player Lastname"; $return_hash{5}{"TABLE"} = "PLAYER"; $return_hash{5}{"FIELD"} = "FIRSTNAME"; $return_hash{5}{"TITLE"} = "Player Firstname"; #$return_hash{6}{"TABLE"} = "REG_DEFINITION"; #$return_hash{6}{"FIELD"} = "7"; #$return_hash{6}{"TITLE"} = "DOB"; #$return_hash{7}{"TABLE"} = "REG_DEFINITION"; #$return_hash{7}{"FIELD"} = "6"; #$return_hash{7}{"TITLE"} = "Gender"; $return_hash{8}{"TABLE"} = "PLAYER"; $return_hash{8}{"FIELD"} = "REG_DATE"; $return_hash{8}{"TITLE"} = "Registration Date"; $return_hash{9}{"TABLE"} = "REG_DEFINITION"; #$return_hash{9}{"FIELD"} = "36"; #dev #$return_hash{9}{"FIELD"} = "514"; #2010 plymouth $return_hash{9}{"FIELD"} = "1121"; #2011 plymouth $return_hash{9}{"TITLE"} = "Gender / Age Group"; }elsif($org_id == 7){ $return_hash{1}{"TABLE"} = "USER"; $return_hash{1}{"FIELD"} = "LASTNAME"; $return_hash{1}{"TITLE"} = "Account Lastname"; $return_hash{2}{"TABLE"} = "USER"; $return_hash{2}{"FIELD"} = "FIRSTNAME"; $return_hash{2}{"TITLE"} = "Account Firstname"; $return_hash{3}{"TABLE"} = "USER"; $return_hash{3}{"FIELD"} = "HOMEPHONE"; $return_hash{3}{"TITLE"} = "Home Phone"; $return_hash{4}{"TABLE"} = "PLAYER"; $return_hash{4}{"FIELD"} = "LASTNAME"; $return_hash{4}{"TITLE"} = "Player Lastname"; $return_hash{5}{"TABLE"} = "PLAYER"; $return_hash{5}{"FIELD"} = "FIRSTNAME"; $return_hash{5}{"TITLE"} = "Player Firstname"; #$return_hash{6}{"TABLE"} = "REG_DEFINITION"; #$return_hash{6}{"FIELD"} = "7"; #$return_hash{6}{"TITLE"} = "DOB"; #$return_hash{7}{"TABLE"} = "REG_DEFINITION"; #$return_hash{7}{"FIELD"} = "6"; #$return_hash{7}{"TITLE"} = "Gender"; $return_hash{8}{"TABLE"} = "PLAYER"; $return_hash{8}{"FIELD"} = "REG_DATE"; $return_hash{8}{"TITLE"} = "Registration Date"; #$return_hash{9}{"TABLE"} = "REG_DEFINITION"; #$return_hash{9}{"FIELD"} = "36"; #$return_hash{9}{"TITLE"} = "Team"; }else{ $return_hash{1}{"TABLE"} = "USER"; $return_hash{1}{"FIELD"} = "LASTNAME"; $return_hash{1}{"TITLE"} = "Account Lastname"; $return_hash{2}{"TABLE"} = "USER"; $return_hash{2}{"FIELD"} = "FIRSTNAME"; $return_hash{2}{"TITLE"} = "Account Firstname"; $return_hash{3}{"TABLE"} = "USER"; $return_hash{3}{"FIELD"} = "HOMEPHONE"; $return_hash{3}{"TITLE"} = "Home Phone"; $return_hash{4}{"TABLE"} = "PLAYER"; $return_hash{4}{"FIELD"} = "LASTNAME"; $return_hash{4}{"TITLE"} = "Player Lastname"; $return_hash{5}{"TABLE"} = "PLAYER"; $return_hash{5}{"FIELD"} = "FIRSTNAME"; $return_hash{5}{"TITLE"} = "Player Firstname"; #$return_hash{6}{"TABLE"} = "REG_DEFINITION"; #$return_hash{6}{"FIELD"} = "7"; #$return_hash{6}{"TITLE"} = "DOB"; #$return_hash{7}{"TABLE"} = "REG_DEFINITION"; #$return_hash{7}{"FIELD"} = "6"; #$return_hash{7}{"TITLE"} = "Gender"; $return_hash{8}{"TABLE"} = "PLAYER"; $return_hash{8}{"FIELD"} = "REG_DATE"; $return_hash{8}{"TITLE"} = "Registration Date"; } return %return_hash; } sub get_column_headers{ #my $org_id = shift; #my $reg_year = 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{$Order} = $Description_Text; } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } sub get_player_header2{ $player_header3 = "cal_events_head"; my $player_header = "Edit Player \n"; $player_header .= "Player Last Name \n"; $player_header .= "Player First Name \n"; $player_header .= "Registration Date \n"; $player_header .= "Total \n"; $player_header .= "Adjustment \n"; $player_header .= "Paid \n"; $player_header .= "Due \n"; $player_header .= "Gender \n"; $player_header .= "DOB
Player \n"; $player_header .= "Grade \n"; $player_header .= "School \n"; $player_header .= "Returning
Player \n"; $player_header .= "Play Up? \n"; $player_header .= "Account
Last Name \n"; $player_header .= "Account
First Name \n"; $player_header .= "Account
Phone \n"; $player_header .= "Account
Email \n"; return $player_header; } sub get_player_header{ $player_header3 = "cal_events_head"; my $player_header = "NamePaid \n"; $player_header .= "Division \n"; $player_header .= "DOB \n"; $player_header .= "Gender \n"; $player_header .= "School \n"; $player_header .= "Grade \n"; $player_header .= "Returning
Player \n"; $player_header .= "Play
Up \n"; $player_header .= "Emergency Contact \n"; $player_header .= "Emergency Phone \n"; $player_header .= "Emergency Secondary Phone \n"; $player_header .= "Hat Size \n"; $player_header .= "Hat Size \n"; return $player_header; } sub print_show_reg_style{ print <<__HTML__; __HTML__ } ####################################### # Get Option values for reg status ####################################### sub get_team_options{ my $value_selected = shift; my $filter_count = shift; my $javascript_menu = "filter_options[$filter_count] = new Array();\n"; my $javascript_menu_map = "filter_options_map[$filter_count] = new Array();\n"; $javascript_menu .= "filter_options[$filter_count][0] = \"Choose Option\";\n"; $javascript_menu_map .= "filter_options_map[$filter_count][0] = -1;\n"; my $count = 1; my $options = ""; $options .= ""; my %leagues_and_teams_lookup = get_leagues_and_teams_by_org_for_id_lookup($org_id); foreach my $league (keys %leagues_and_teams_lookup){ foreach my $team_id (sort {$leagues_and_teams_lookup{$league}{$a} cmp $leagues_and_teams_lookup{$league}{$b}} keys %{$leagues_and_teams_lookup{$league}}){ if($team_id ne "LEAGUE_NAME"){ my $selected = ""; my $team = $leagues_and_teams_lookup{$league}{$team_id}; if($value_selected == $team_id){ $selected = "SELECTED"; } $options .= ""; #$options = ""; #print "SK: $status_key $status_selected $status_hash $status_hash{$status_key}{'DESC'}
"; $javascript_menu .= "filter_options[$filter_count][$count] = \"$team\";\n"; $javascript_menu_map .= "filter_options_map[$filter_count][$count] = $team_id;\n"; $count++; } } } my $return_js = $javascript_menu . "\n" . $javascript_menu_map . "\n"; return $options, $return_js; } ####################################### # Get Option values for reg status ####################################### sub get_status_options{ my $value_selected = shift; my $filter_count = shift; my %status_hash = get_status_hash($org_id, $reg_year); my $status_options = ""; $status_options .= ""; my $count = 1; my $javascript_menu = "filter_options[$filter_count] = new Array();\n"; my $javascript_menu_map = "filter_options_map[$filter_count] = new Array();\n"; $javascript_menu .= "filter_options[$filter_count][0] = \"Choose Option\";\n"; $javascript_menu_map .= "filter_options_map[$filter_count][0] = -1;\n"; foreach my $status_key (sort {$a <=> $b} keys %status_hash){ my $status_selected = ""; if($value_selected == $status_key){ $status_selected = "SELECTED"; } $status_options .= ""; #print "SK: $status_key $status_selected $status_hash $status_hash{$status_key}{'DESC'}
"; $javascript_menu .= "filter_options[$filter_count][$count] = \"$status_hash{$status_key}{'DESC'}\";\n"; $javascript_menu_map .= "filter_options_map[$filter_count][$count] = $status_key;\n"; $count++; } my $return_js = $javascript_menu . "\n" . $javascript_menu_map . "\n"; return $status_options, $return_js; } ####################################### # Get filter parameters ####################################### sub get_filter_values{ my $filter1_field = check_param('filter1_field', 0); my $filter1_value = check_param('filter1_value', 0); #print "FV: $filter1_field - $filter1_value
\n"; my %return_hash; $return_hash{1}{"FILTER_FIELD"} = $filter1_field; $return_hash{1}{"FILTER_VALUE"} = $filter1_value; return %return_hash; } ####################################### # Map filters fields to tables ####################################### sub get_field_user_player_map{ my $filter_ref_hash = shift; my %return_hash; $return_hash{0}{"DISPLAY_FIELD"} = "Choose Filter Category"; $return_hash{0}{"FIELD"} = ""; $return_hash{0}{"TABLE"} = ""; $return_hash{0}{"TYPE"} = ""; #$return_hash{1}{"DISPLAY_FIELD"} = "Select Team"; #$return_hash{1}{"FIELD"} = "Assigned_Team"; #$return_hash{1}{"TABLE"} = "PLAYER"; #$return_hash{1}{"TYPE"} = "DROPDOWN"; $return_hash{1}{"DISPLAY_FIELD"} = "Registration Status"; $return_hash{1}{"FIELD"} = "Player_Confirmed"; $return_hash{1}{"TABLE"} = "PLAYER"; $return_hash{1}{"TYPE"} = "DROPDOWN"; $return_hash{2}{"DISPLAY_FIELD"} = "Gender / Age Group"; #$return_hash{2}{"FIELD"} = "36"; #dev #$return_hash{2}{"FIELD"} = "514"; # 2010 plymouth $return_hash{2}{"FIELD"} = "1121"; # 2010 plymouth $return_hash{2}{"TABLE"} = "REG_DEFINITION"; $return_hash{2}{"TYPE"} = "DROPDOWN"; $return_hash{3}{"DISPLAY_FIELD"} = "Assigned Team"; #$return_hash{3}{"FIELD"} = "38"; #dev #$return_hash{3}{"FIELD"} = "510"; #2010 plymouth $return_hash{3}{"FIELD"} = "1117"; #2011 plymouth $return_hash{3}{"TABLE"} = "REG_DEFINITION"; $return_hash{3}{"TYPE"} = "DROPDOWN"; return %return_hash; } ####################################### # Get filter parameters ####################################### sub get_query_filters{ my $filter_hash_ref = shift; my %filters = %{$filter_hash_ref}; my %filter_map = get_field_user_player_map(); my $player_query = ""; my $account_query = ""; my %reg_def_filter = (); my %return_hash; foreach my $filter_count (keys %filters){ #print "FC: $filter_count - F: " . $filters{"$filter_count"}{"FILTER_FIELD"} . " - " . $filters{"$filter_count"}{"FILTER_VALUE"} . "
\n"; my $filter_field = $filters{$filter_count}{"FILTER_FIELD"}; my $filter_value = $filters{$filter_count}{"FILTER_VALUE"}; if($filter_map{$filter_field}{"TABLE"} eq "PLAYER"){ $player_query .= " AND " . $filter_map{$filter_field}{"FIELD"} . " = '$filter_value'"; }elsif($filter_map{$filter_field}{"TABLE"} eq "REG_DEFINITION"){ my $filter_key_id = $filter_map{$filter_field}{"FIELD"}; $reg_def_filter{$filter_key_id} = get_option_value_for_filter($filter_value); #"Boys U14"; } } $return_hash{"PLAYER_QUERY"} = $player_query; $return_hash{"ACCOUNT_QUERY"} = $account_query; $return_hash{"REG_DEF_FILTER"} = \%reg_def_filter; return %return_hash; } ####################################### # Check if a value is defined otherwise # set to defaults ####################################### sub check_param{ my $param = shift; my $default = shift; my $return_value = param($param); if(!(defined($return_value))){ $return_value = $default; } return $return_value; } sub get_filter_value_options{ my $filter_key = shift; my $value_selected = shift; my $js_menu_options = ""; #print "FILTER: $filter_key VALUE: $value_selected
\n"; my $return_string = ""; if(!(defined($filter_key))){$filter_key = 0;} if($filter_key == 0){ $return_string = ""; #print "IN FILTER MAP: $filter_key
\n"; }elsif($filter_key == 6){ # currently not used ($return_string, $js_options) = get_team_options($value_selected, $filter_key); $js_menu_options .= $js_options; #print "RS: $return_string
\n"; #print "IN FILTER MAP: $js_status_options
\n"; }elsif($filter_key == 1){ #print "VALUE: $value_selected FILTER: $filter_key -
\n"; ($return_string, $js_status_options) = get_status_options($value_selected, $filter_key); $js_menu_options .= $js_status_options; #print "IN FILTER MAP: $js_status_options
\n"; }elsif(($filter_key == 2)||($filter_key == 3)){ my %filter_map = get_field_user_player_map(); my $reg_def_key = $filter_map{$filter_key}{"FIELD"}; #print "VALUE: $value_selected FILTER: $filter_key - $reg_def_key
\n"; ($return_string, $js_menu_options) = get_reg_definition_options($value_selected, $filter_key, $reg_def_key); #print "OPTIONS: $return_string
JS: $js_menu_options\n"; } return $return_string, $js_menu_options; } sub get_reg_definition_options{ my $value_selected = shift; my $filter_count = shift; my $reg_def_key = shift; my $javascript_menu = "filter_options[$filter_count] = new Array();\n"; my $javascript_menu_map = "filter_options_map[$filter_count] = new Array();\n"; my $count = 0; my $options = ""; my $return_js = ""; my %reg_item_definition = get_specific_reg_definition($org_id, $reg_year, 0, $reg_def_key); my $input_type = $reg_item_definition{"INPUT_TYPE"}; #print "INPUT TYPE: $input_type - $reg_def_key\n"; if(($input_type == 3)||($input_type == 13)){ ($options, $return_js) = get_options_for_filter($reg_def_key, $value_selected, $filter_count); } #print "OPTIONS: $options
JS: $return_js\n"; return $options, $return_js; } sub get_pop_filter_js{ my $return_js = <<__HTML__; function popFilter(){ var filterValEL = document.getElementById('filter1_value'); filterValEL.options.length=0; var filterFieldEL = document.getElementById('filter1_field'); //var filter_lookup = filter_options_map[filterFieldEL.value]; //alert(filterFieldEL.value); filter_lookup = filterFieldEL.value; //alert(filter_lookup); for(i=0; i $b} keys %filter_map){ my $filter_field_selected = ""; my $display_field = $filter_map{$filter_key}{"DISPLAY_FIELD"}; #print $filters{$filter_count}{"FILTER_FIELD"} . " = $filter_key
\n"; if($filters{$filter_count}{"FILTER_FIELD"} == $filter_key){ $filter_field_selected = "SELECTED"; my $filter_value_selected = $filters{$filter_count}{"FILTER_VALUE"}; ($filter_value_options, $tmp_js) = get_filter_value_options($filter_key, $filter_value_selected); #print "FVJO: $filter_value_options
\n"; $js_menu_options = $js_menu_options . $tmp_js; }else{ ($non_default_filter_value_options, $tmp_js) = get_filter_value_options($filter_key, 0); $js_menu_options = $js_menu_options . $tmp_js; } $filter_box .= ""; } $filter_box .= ""; $filter_box .= ""; #$filter_box .= "Apply Filter\n"; $filter_box .= "Remove Filter\n"; $filter_box = "\n" . $filter_box; return $filter_box; } ####################################### # This one shows the user on top of the player ####################################### sub print_show_reg_enrollment_report{ #my %users = get_users_by_org($org_id); my %filters = get_filter_values(); my %query_filters = get_query_filters(\%filters); my $reg_def_filter_ref = $query_filters{"REG_DEF_FILTER"}; my %reg_def_filters = %{$reg_def_filter_ref}; my %users = get_users_by_org_with_filter($org_id, $filter1_field, $query_filters{"ACCOUNT_QUERY"}); my %status_hash = get_status_hash($org_id, $reg_year); my $all_player_row = ""; my $player_count = 0; #my $status_options = get_status_options(\%status_hash); #my %users = get_users_by_org($org_id); print_show_reg_style(); print "
\n"; my $filter_box = get_filter_box(\%filters); my $player_header = get_player_header_dynamic_enrollment($require_confirmation, $league_assign_on); my $player_header1 = "cal_events3"; my $player_header2 = "cal_events2"; $table_header = "
"; $table_header .= ""; $table_header .= ""; $table_header .= "\n"; $table_header .= "
\n"; $table_header .= "$filter_box
\n"; #$table_header .= "NEW Player Report\n"; #$table_header .= "Export to Excel\n"; $table_header .= "
\n"; $table_header .= "\n"; $table = $table_header . $player_header; %player_info = (); my %column_headers = get_column_headers_report_enrollment(); my %leagues_and_teams_lookup = get_leagues_and_teams_by_org_for_id_lookup($org_id); my %reg_definition = get_reg_definition_hash($org_id, $reg_year); ######################################## # Loop through users ######################################## foreach my $user_key (sort { lc($users{$a}{"LASTNAME"}) cmp lc($users{$b}{"LASTNAME"}) || lc($users{$a}{"FIRSTNAME"}) cmp lc($users{$b}{"FIRSTNAME"})} keys %users) { ######################################## # Loop through players for that user ######################################## my %tmp_player_info = get_player_info_with_filter($user_key,$query_filters{"PLAYER_QUERY"}); foreach my $player_order (sort{$a <=> $b}keys %tmp_player_info){ my %pre_defined_cells; my $filter_on_reg_def = 0; my $player_row = ""; ######################################## # Loop through report for that player ######################################## my $player_key = $tmp_player_info{$player_order}{"KEY"}; my $player_status = $tmp_player_info{$player_order}{"PLAYER_CONFIRMED"}; my $player_league_assigned = $tmp_player_info{$player_order}{"ASSIGNED_LEAGUE"}; my $player_team_assigned = $tmp_player_info{$player_order}{"ASSIGNED_TEAM"}; my $player_active = $tmp_player_info{$player_order}{"ACTIVE"}; my $display_status = $status_hash{$player_status}{"DESC"}; my $accepted_state = $status_hash{$player_status}{"ACCEPTED_STATE"}; #my %extra_player_data = get_reg_values_by_player($org_id, $reg_year, $player_key); my %extra_player_data = get_reg_values_by_player_from_hash($org_id, $reg_year, $player_key, \%reg_definition); ######################################## # Check if player is assigned to a team or league ######################################## my $assigned_status = "Unassigned"; my $assigned_league = ""; my $assigned_team = ""; if($player_league_assigned != 0){ $assigned_status = "League Assigned"; $assigned_league = $leagues_and_teams_lookup{$player_league_assigned}{"LEAGUE_NAME"}; } if($player_team_assigned != 0){ $assigned_status = "Team Assigned"; $assigned_team = $leagues_and_teams_lookup{$player_league_assigned}{$player_team_assigned}; } #my ($total, %adjustment_info) = get_adjustment_info($player_key); my ($total, $total_fee, $total_paid, %adjustment_info) = get_adjustment_info($player_key); $total = sprintf("%.2f", $total_fee); $due = sprintf("%.2f", $total+$total_paid); $total_paid = abs($total_paid); $paid = sprintf("%.2f", $total_paid); if($player_header eq $player_header1){ $player_header = $player_header2; }else{ $player_header = $player_header1; } ###################################### # Get Paid or not Pay status ###################################### my $pay_status = "Not Paid"; if($paid >= $due){ $pay_status = "Paid"; } #$player_row .= "\n"; #$player_row .= "\n"; $player_row .= ""; $pre_defined_cells{"PAY_STATUS"} = "$pay_status\n"; #$player_row .= "\n"; $pre_defined_cells{"EMAIL"} = "
\n"; if($require_confirmation == 1){ #$player_row .= "
\n"; if($accepted_state == -1){ $pre_defined_cells{"DISPLAY_STATUS"} = "
$display_status\n"; }else{ $pre_defined_cells{"DISPLAY_STATUS"} = "
$display_status\n"; } } if($league_assign_on == 1){ #$player_row .= "
\n"; $pre_defined_cells{"ASSIGN_STATUS"} = "
$assigned_status\n"; #$player_row .= "
\n"; $pre_defined_cells{"ASSIGNED_LEAGUE"} = "$assigned_league\n"; #$player_row .= "\n"; $pre_defined_cells{"ASSIGNED_TEAM"} = "$assigned_team\n"; } #$player_row .= "\n"; #$player_row .= "\n"; #$player_row .= "\n"; #$player_row .= "\n"; foreach $order (sort{$a <=> $b}keys %column_headers){ $content = ""; if($column_headers{$order}{"TABLE"} eq "USER"){ $content = $users{$user_key}{$column_headers{$order}{"FIELD"}}; }elsif($column_headers{$order}{"TABLE"} eq "PLAYER"){ $content = $tmp_player_info{$player_order}{$column_headers{$order}{"FIELD"}}; }elsif($column_headers{$order}{"TABLE"} eq "PRE_DEFINED"){ my $pre_defined_field = $column_headers{$order}{"FIELD"}; $content = $pre_defined_cells{$pre_defined_field}; }else{ $content = $extra_player_data{$column_headers{$order}{"FIELD"}} ; #print "EPI: " . $column_headers{$order}{"FIELD"} . "-" . $extra_player_data{$column_headers{$order}{"FIELD"}} . "
\n"; my $reg_def_field_key = $column_headers{$order}{"FIELD"}; if(defined($reg_def_filters{$reg_def_field_key})){ #print "EPD: " . $extra_player_data{$column_headers{$order}{"FIELD"}} . " - " . $reg_def_filters{$reg_def_field_key} . "
\n"; $filter_on_reg_def = 1; #print "TURNING Filter off
\n"; if($extra_player_data{$column_headers{$order}{"FIELD"}} eq $reg_def_filters{$reg_def_field_key}){ #print "TURNING Filter on
\n"; $filter_on_reg_def = 0; } } } $player_row .= ""; } $player_row .= "\n"; my $show_row = 1; if(($player_active == 0)&&($accepted_state != -1)){ $show_row = 0; } if(($filter_on_reg_def == 0)&&($show_row == 1)){ $player_count++; $all_player_row .= $player_row; } } } $all_player_row .= "
aaaedit
$pay_status
$display_status
$assigned_status
$assigned_league$assigned_team\$$total\$" . $paid . "\$" . $due . "
edit$content
\n"; $table .= $all_player_row; #print $table; print "
Total Records Found: $player_count
" . $table; } sub sort_lastname_firstname{ my $hash_ref = shift; my %hash = %{$hash_ref}; lc($hash{$a}{"LASTNAME"}) cmp lc($hash{$b}{"LASTNAME"}); } sub get_regular_reg_filter{ my $current_filter_value = shift; my %selected_options ; $selected_options{-1} = ""; $selected_options{1} = ""; $selected_options{2} = ""; $selected_options{3} = ""; my $found_match = 0; my $values = ""; foreach my $value (sort{$a <=> $b} keys %selected_options){ if($current_filter_value == $value){ print "VALUE: $value
\n"; $selected_options{$value} = "SELECTED"; $found_match = 1; } } if($found_match == 0){ $selected_options{-1} = "SELECTED"; } my $filter_box = ""; $filter_box .= "Remove Filter\n"; return $filter_box; } sub get_normal_reg_filter_show_row{ my $total = shift; my $due = shift; my $filter_value = shift; my $balance_due = 0; my $paid_in_full = 0; my $show_row = 0; ################################### # Get total that have a balance due ################################### if(($total >0) && ($due > 0)){ $balance_due = 1; } if(($filter_value == -1)|| ($filter_value == 0) || ($filter_value == 3)){ # Show all rows $show_row = 1; }elsif($filter_value == 1){ # Registrants with Balance Due if(($total >0) && ($due > 0)){ $show_row = 1; $balance_due = 1; } }elsif($filter_value == 2){ # Registrants who have Paid in Full if(($total >0) && ($due <= 0)){ $show_row = 1; $paid_in_full = 1; } }else{ # should not get here... $show_row = 1; } return ($show_row, $balance_due, $paid_in_full); } ####################################### # This one shows the user on top of the player ####################################### sub print_show_reg{ my %users = get_users_by_org($org_id); my $shown_player_count = 0; my $total_player_count = 0; my $balance_due_count = 0; my $paid_in_full_count = 0; #################################################################### # Get filter fields and store as hidden fields #################################################################### my %filters = get_filter_values(); my $filter1_field = $filters{'1'}{"FILTER_FIELD"}; my $filter1_value = $filters{'1'}{"FILTER_VALUE"}; my $filter_box = get_regular_reg_filter($filter1_value); print_show_reg_style(); print "
\n"; my $player_header = get_player_header_dynamic(); my $player_header1 = "cal_events3"; my $player_header2 = "cal_events2"; $table_header = "
"; $table_header .= ""; $table_header .= ""; $table_header .= "\n"; $table_header .= "
\n"; $table_header .= "$filter_box"; #$table_header .= "NEW Player Report\n"; #$table_header .= "Export to Excel\n"; $table_header .= "
\n"; $table_header .= "\n"; $table = $table_header . $player_header; %player_info = (); my %column_headers = get_column_headers_report(); my %reg_definition = get_reg_definition_hash($org_id, $reg_year); ######################################## # Loop through users ######################################## my $user_hash_ref = \%users; foreach my $user_key (sort { lc($users{$a}{"LASTNAME"}) cmp lc($users{$b}{"LASTNAME"}) || lc($users{$a}{"FIRSTNAME"}) cmp lc($users{$b}{"FIRSTNAME"}) } keys %users) { ######################################## # Loop through players for that user ######################################## my %tmp_player_info = get_player_info($user_key); foreach my $player_order (sort{$a <=> $b} keys %tmp_player_info){ my $this_player_row = ""; ######################################## # Loop through report for that player ######################################## $player_key = $tmp_player_info{$player_order}{"KEY"}; #my %extra_player_data = get_reg_values_by_player($org_id, $reg_year, $player_key); my %extra_player_data = get_reg_values_by_player_from_hash($org_id, $reg_year, $player_key, \%reg_definition); #my ($total, %adjustment_info) = get_adjustment_info($player_key); my ($total, $total_fee, $total_paid, %adjustment_info) = get_adjustment_info($player_key); $total = sprintf("%.2f", $total_fee); $due = sprintf("%.2f", $total+$total_paid); $total_paid = abs($total_paid); $paid = sprintf("%.2f", $total_paid); if($player_header eq $player_header1){ $player_header = $player_header2; }else{ $player_header = $player_header1; } $this_player_row .= "\n"; $this_player_row .= "\n"; $this_player_row .= "\n"; $this_player_row .= "\n"; $this_player_row .= "\n"; #$player_row .= "\n"; foreach $order (sort{$a <=> $b}keys %column_headers){ $content = ""; if($column_headers{$order}{"TABLE"} eq "USER"){ $content = $users{$user_key}{$column_headers{$order}{"FIELD"}}; }elsif($column_headers{$order}{"TABLE"} eq "PLAYER"){ $content = $tmp_player_info{$player_order}{$column_headers{$order}{"FIELD"}}; }else{ $content = $extra_player_data{$column_headers{$order}{"FIELD"}}; } $this_player_row .= ""; } $this_player_row .= "\n"; ################################################## # If the filter is on determine if this row is shown ################################################## my ($show_row, $balance_due, $paid_in_full) = get_normal_reg_filter_show_row($total, $due, $filter1_value); if($show_row == 1){ $player_row .= $this_player_row; $shown_player_count++; $balance_due_count = $balance_due_count + $balance_due; $paid_in_full_count = $paid_in_full_count + $paid_in_full; } $total_player_count++; } } $player_row .= "
editremove\$$total\$" . $paid . "\$" . $due . "
edit$content
\n"; $table .= $player_row; my $reg_all_comm_group = $reg_year . "ALL"; my $reg_bal_due_comm_group = $reg_year . "BalDue"; my $view_email_regAll = ""; my $view_email_regBalDue = ""; my $view_comm_link = "View Communications History"; #print "
$season_text
Total Records Found: $player_count
" . $table; print "
$season_text
" . $view_email_regAll . "Send Email to All Registrants ($total_player_count)
" . $view_email_regBalDue . "Send Email to Registrants with a Balance Due($balance_due_count)
$view_comm_link
Total Records Found: $shown_player_count
" . $table; } sub get_players_from_account_id{ my $account_id = shift; 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(); } sub process_for_csv{ my $input_string = shift; $input_string =~ s/\"/\"\"/g; #$input_string = '"' . $input_string . '",'; $input_string = '"' . $input_string . '"' . "\t"; $input_string .= s/\r//g; return $input_string; } sub get_paypal_info_for_csv{ my $last_name = shift; my $first_name = shift; my $player_key = shift; my $return_string = ""; my $amount = 0; $player_header1 = "cal_events3"; $player_header2 = "cal_events2"; $user_header = "date_header"; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Amount`, `PP_Transaction_ID`, `Date` FROM `Reg_Paypal` WHERE `Player_ID` = '$player_key' AND `Processed` = '1';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Amount, \$PP_Transaction_ID, \$Date); while($sth->fetch()) { #$return_string .= "$last_name$first_name$Amount$PP_Transaction_ID$DatePayPal"; $return_string .= "PayPal | $first_name $last_name | $Amount | $PP_Transaction_ID | $Date\n"; $return_amount = $return_amount + $amount; } # disconnect from database $sth->finish(); $dbh->disconnect; #print "RP: $return_password
\n"; return $return_string, $amount; } ####################################### # This one shows the user in line with the player ####################################### sub print_show_reg_csv{ my %users = get_users_by_org($org_id); #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 %division_selected = get_division_data(); my $reg_report = "$teamdata/$org_id/regusers.csv"; my $player_header_info = get_player_header2(); my $player_header_info_csv = get_player_header8_tab(); #$table_header = "\n"; #$table_header = "
\n"; $table_header = "
Export to Excel2Export to Excel
\n"; $user_header = "date_header"; $player_header3 = "player_header"; $player_header1 = "cal_events3"; $player_header2 = "cal_events2"; $currnet_header = 2; $full_user_info = ""; %player_info = (); foreach my $user_key (keys %users) { $html_user = "\n"; $html_user .= " \n"; my %tmp_player_info = get_player_info2($user_key); $paid = 0; $html = ""; my $num_players = 0; foreach my $player_key (sort {$a <=> $b}(keys %tmp_player_info)) { $player_info{$player_key}{"ULASTNAME"} = $users{$user_key}{"LASTNAME"}; $player_info{$player_key}{"UFIRSTNAME"} = $users{$user_key}{"FIRSTNAME"}; $player_info{$player_key}{"UHOMEPHONE"} = $users{$user_key}{"HOMEPHONE"}; $player_info{$player_key}{"UEMAIL"} = $users{$user_key}{"EMAIL"}; $player_info{$player_key}{"UWORK_PHONE"} = $users{$user_key}{"WORK_PHONE"}; $player_info{$player_key}{"UMOBILE_PHONE"} = $users{$user_key}{"MOBILE_PHONE"}; $player_info{$player_key}{"UZIP_CODE"} = $users{$user_key}{"ZIP_CODE"}; $player_info{$player_key}{"UADDRESS1"} = $users{$user_key}{"ADDRESS1"}; $player_info{$player_key}{"UADDRESS2"} = $users{$user_key}{"ADDRESS2"}; $player_info{$player_key}{"UCITY"} = $users{$user_key}{"CITY"}; $player_info{$player_key}{"USTATE"} = $users{$user_key}{"STATE"}; ##########################################################3 # Calculate amount total, paid and due ########################################################### $num_players++; my $base_cost = is_older_than_cutoff($tmp_player_info{$player_key}{"DOB"},$tmp_player_info{$player_key}{"GENDER"}); $amount_paid = $tmp_player_info{$player_key}{"PAID"}; if($num_players > 2){$fundraiser_fee = 0; $fundraiser_string = "";}else{$fundraiser_fee = 30; $fundraiser_string = "+ \$30 Fundraiser";} if($num_players > 1){$discount = 15; $discount_string = "-\$15 multiplayer discount";}else{$discount = 0;$discount_string = "";} $player_total = $base_cost + $fundraiser_fee - $discount; $player_total_csv = $base_cost - $discount; # Removed Fundraiser from total $tmp_player_info{$player_key}{"ADJUSTMENT"} = get_player_adjustment($player_key); $amount_due_csv = $player_total - $amount_paid + $tmp_player_info{$player_key}{"ADJUSTMENT"}; my ($tmp_pay_pal_info, $paypal_player_amount) = get_paypal_info_for_csv($tmp_player_info{$player_key}{"LASTNAME"}, $tmp_player_info{$player_key}{"FIRSTNAME"}, $player_key); my ($tmp_transaction_info, $tx_player_amount) = get_transaction_info_for_csv($tmp_player_info{$player_key}{"LASTNAME"}, $tmp_player_info{$player_key}{"FIRSTNAME"}, $player_key); my %player_adjustments = get_player_adjustment2($player_key); $tmp_player_info{$player_key}{"PAY_INFO"} = $tmp_pay_pal_info . $tmp_transaction_info; #$tmp_player_info{$player_key}{"ADJUSTMENT"} = $player_adjustments{"OTHER"}; $tmp_player_info{$player_key}{"LATE_FEE"} = $player_adjustments{"WALK_IN"}; $tmp_player_info{$player_key}{"FUNDRAISER"} = $fundraiser_fee; my $total_adjustment = $player_adjustments{"OTHER"} + $player_adjustments{"WALK_IN"}; $player_total_csv = $player_total + $player_adjustments{"OTHER"}; #$tmp_player_info{$player_key}{"ADJUSTMENT"} = get_player_adjustment2($player_key); $amount_due = $player_total - $amount_paid + $total_adjustment; $tmp_player_info{$player_key}{"TOTAL_DUE"} = $player_total; $tmp_player_info{$player_key}{"TOTAL_DUE_CSV"} = $player_total_csv; $tmp_player_info{$player_key}{"AMOUNT_DUE"} = $amount_due; foreach my $player_field (keys %{$tmp_player_info{$player_key}}){ $player_info{$player_key}{"$player_field"} = $tmp_player_info{$player_key}{$player_field}; } } } foreach my $player_key (sort {lc($player_info{$a}{"LASTNAME"}) cmp lc($player_info{$b}{"LASTNAME"})} (keys %player_info)) { my @field_list = ("LASTNAME", "FIRSTNAME","HAT_SIZE", "TOTAL_DUE", "ADJUSTMENT", "PAID", "AMOUNT_DUE" ,"GENDER","DOB","GRADE","SNAME","RETURNING","PLAY_UP","ULASTNAME","UFIRSTNAME","UHOMEPHONE","UEMAIL"); if($player_header eq $player_header1){ $player_header = $player_header2; }else{ $player_header = $player_header1; } $paid = $paid + $player_info{$player_key}{"PAID"}; $player_info = " \n"; $player_info_csv = ""; foreach(@field_list){ #$player_info_csv .= process_for_csv($player_info{$player_key}{$_}); if($_ eq "PAID"){ $player_info .= " \n"; }elsif($_ eq "ADJUSTMENT"){ $player_info .= " \n"; }elsif($_ eq "HAT_SIZE"){ $display_date = convert_date_no_time_to_display($player_info{$player_key}{$_}); $player_info .= "\n"; }else{ $player_info .= "\n"; } } my @csv_field_list = ("LASTNAME", "FIRSTNAME", "HAT_SIZE", "DOB", "GENDER", "SNAME", "GRADE", "E_CONTACT_NAME", "E_CONTACT_PHONE", "E_CONTACT_SPHONE", "E_CONTACT_REL", "G_CONTACT_PHONE", "G_CONTACT_SPHONE", "G_CONTACT_NAME", "G_CONTACT_REL", "OG_CONTACT_PHONE", "OG_CONTACT_SPHONE", "OG_CONTACT_NAME", "OG_CONTACT_REL", "PREF_DOC_NAME", "PREF_DOC_NUMB", "PREF_DENT_NAME", "PREF_DENT_NUMB", "PREF_HOSPITAL", "INSURANCE", "POLICY", "MEDICAL", "RETURNING", "PAID", "TOTAL_DUE_CSV", "FUNDRAISER", "ADJUSTMENT", "LATE_FEE", "PAY_INFO", "CONSENT", "ACTIONSTO", "PLAY_UP", "ULASTNAME", "UFIRSTNAME", "UEMAIL", "UADDRESS1", "UADDRESS2", "UCITY", "USTATE", "UZIP_CODE", "UHOMEPHONE", "UMOBILE_PHONE"); foreach(@csv_field_list){ $player_info_csv .= process_for_csv($player_info{$player_key}{$_}); } $player_info .= ""; $full_user_info .= $player_info; $player_info_csv .= "\n"; $full_user_csv_info .= $player_info_csv; } $full_user_info .= "
$users{$user_key}{\"LASTNAME\"}, $users{$user_key}{\"FIRSTNAME\"}$users{$user_key}{\"HOMEPHONE\"}
edit$player_info{$player_key}{$_}$player_info{$player_key}{$_}$display_date $player_info{$player_key}{$_}
\n"; #print $table_header . $player_header_info . $full_user_info . "

 "; #if(-e $reg_report){ `rm $reg_report`;} #open(OUT, ">$reg_report") || die "ERROR: Could not create regusers. $!
"; #print OUT $player_header_info_csv . "\n" . $full_user_csv_info; #print "$teamdata" . $player_header_info_csv . "\n" . $full_user_csv_info; #close(OUT); return $player_header_info_csv . "\n" . $full_user_csv_info; } sub get_transaction_info_for_csv{ my $last_name = shift; my $first_name = shift; my $player_key = shift; my $return_string = ""; my $amount = 0; $player_header1 = "cal_events3"; $player_header2 = "cal_events2"; $user_header = "date_header"; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT a.`Amount`, a.`Check_ID`, a.`Date`, b.`Login` FROM `Reg_All_Transaction` a, `Account_Info` b WHERE a.`Player_ID` = '$player_key' AND b.`Key` = a.`Update_Account_ID`;"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Amount, \$Check_ID, \$Date, \$Login); while($sth->fetch()) { #$return_string .= "$last_name$first_name$Amount$Check_ID$Date$Login"; $return_string .= "Manual | $first_name $last_name | $Amount | $Check_ID | $Date\n"; $return_amount = $return_amount + $amount; } # disconnect from database $sth->finish(); $dbh->disconnect; #print "RP: $return_password
\n"; return $return_string, $amount; } sub get_player_adjustment2{ my $player_key = shift; my $walk_in_adjustment = 0; my $other_adjustment = 0; my $dbh = get_dbh(); my %reutrn_hash = (); $return_hash{"WALK_IN"} = 0; $return_hash{"OTHER"} = 0; my $query = "SELECT `Key`,`Amount`,`Check_ID` FROM `Reg_All_Transaction` WHERE `Player_ID` = '$player_key';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Key,\$Amount,\$Check_ID); while($sth->fetch()) { if($Check_ID eq "Walk In"){ $walk_in_adjustment = $walk_in_adjustment + $Amount; $return_hash{"WALK_IN"} = $walk_in_adjustment; }else{ $other_adjustment = $other_adjustment + $Amount; $return_hash{"OTHER"} = $other_adjustment; } } $sth->finish(); # disconnect from database $dbh->disconnect; return %return_hash; } sub get_player_adjustment{ my $player_key = shift; my $adjustment = 0; my $dbh = get_dbh(); my $query = "SELECT `Amount` FROM `Reg_All_Transaction` WHERE `Player_ID` = '$player_key';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Amount); while($sth->fetch()) { $adjustment = $adjustment + $Amount; } $sth->finish(); # disconnect from database $dbh->disconnect; return $adjustment; } sub print_steps{ print_reg_style(); print "
\n"; print <<__HTML__;
 
__HTML__ } sub print_no_steps{ print_reg_style(); print "
\n"; print <<__HTML__;
 
__HTML__ } sub print_step_choices{ if($action eq "step2"){ ##### Log in to verify USER Account information $email = param('email'); $pw = param('pw'); $session_id = check_reg_login($email, "$pw"); if($session_id eq ""){ print_reg_login("Your username or password was incorrect."); }else{ print_verify_account_info($email); } }elsif($action eq "tmppw"){ $email = param('email'); $pw = param('pw'); $x = param('x'); $newemail = $email; #print "tmp_string: $x
\n"; if(defined($email)){ $bad_user_pass = "Your username or password was incorrect"; }else{ $bad_user_pass = ""; } $valid_tmp_pw = check_tmp_password($email, $pw, $x); if($valid_tmp_pw == 1){ print_create_account(); }else{ print_temp_pw_login($bad_user_pass); #print_send_temp_pw($bad_user_pass); } }elsif($action eq "newaccount"){ ##### Get information to create new USER Account if(check_for_account($newemail)== 0){ print_create_account(); }else{ print_create_new_account_duplicate_email(); } }elsif($action eq "createaccount"){ ##### Create New USER Account, Get information to create new PLAYER Account $email = get_param('email'); if(check_for_account($email)== 0){ ##### Verify Email Account $user_key = createaccount(); } print_verify_account_info($email); #print_register_programs($user_key); }elsif($action eq "modify"){ ##### Get Information to Update USER Account $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ $email = param('email'); print_update_account($email); } }elsif($action eq "modifyaccount"){ ##### Modify USER Account, Verify Information $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ $email = update_account(); print_verify_account_info($email); } }elsif($action eq "forgot_pw"){ print_forgot_pw(); }elsif($action eq "send_pw"){ $found_email = send_pw(); if($found_email == 1){ print_reg_login("Your Password will be sent to you shortly"); }else{ print_forgot_pw("I'm sorry, we could not find that email,
if this problem continues, please
contact support\@hometeamz.com"); } }elsif($action eq "logout"){ print "\n"; print_reg_login("You have successfully logged out."); }elsif($action eq "pp"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay_partial_complete(); } }elsif($payment_s eq "Completed"){ $session_id = check_reg_login(); if($session_id eq ""){ print_reg_login(); }else{ print_pay_partial_complete(); } }else{ print_reg_login(); } print "
\n"; print <<__HTML__; __HTML__ print "\n"; } ############################################ # Step 1. login or create new account ############################################ sub print_forgot_pw{ my $msg = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__; $alert
Step 1: User Login - Retrieve Password
Enter your email and click Get Password and we will email you your password.

Enter Email
Email
__HTML__ print $html; } ########################################### # Modify player info on admin registration ########################################### sub print_modify_player2{ my $player_key = shift; my $org_id = shift; my %mod_player_info = get_player_info_by_key($player_key); my %division_selected = get_division_data(); my @grades = get_grades(); my @relationships = get_relationships(); #print "PLAYER KEY: $player_key
"; my $phone_validation = get_phone_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;

Step 3:Update Player
Please complete the information listed below...
    * Required Fields
__HTML__ #foreach my $div_id (sort { $a <=> $b } keys %division_selected) { # $html .= "\n"; #} $male_selected = ""; $female_selected = ""; $yes_selected = ""; $no_selected = ""; $consent_yes = ""; $consent_no = ""; if($mod_player_info{"CONSENT"} eq "Yes"){ $consent_yes = "CHECKED"; }else{ $consent_no = "CHECKED"; } if($mod_player_info{"GENDER"} eq "male"){ $male_selected = "CHECKED"; }else{ $female_selected = "CHECKED"; } if($mod_player_info{"RETURNING"} eq "Yes"){ $yes_selected = "CHECKED"; }else{ $no_selected = "CHECKED"; } if($mod_player_info{"PLAY_UP"} eq "Yes"){ $play_up = "CHECKED"; }else{ $play_up = ""; } $html .= <<__HTML__; __HTML__ $html .= <<__HTML__;
Player Information
Player First Name*
Player Last Name*
Date of Birth*
Gender* Male Female
School Name
Current Grade Level*
Returning Player* Yes No
Request this Player to play up a League:
Guardian Information
Guardian 1 Name*
Guardian 1 Primary Phone* $phone_example
Guardian 1 Secondary Phone $phone_example
Guardian 1 Relationship*
Guardian 2 Name
Guardian 2 Primary Phone $phone_example
Guardian 2 Secondary Phone $phone_example
Guardian 2 Relationship
Emergency Contact Information
Emergency Contact Name*
Emergency Contact Primary Phone* $phone_example
Emergency Contact Secondary Phone $phone_example
Emergency Contact Relationship*
Medical Information
Preferred Doctor Name
Preferred Doctor Phone $phone_example
Preferred Dentist Name
Preferred Dentist Phone $phone_example
Preferred Hospital
Insurance Carrier
Policy Number
Medical History:
Allergies, Medications,
Special Condition, etc
GRANT OF CONSENT * (please select one for the player listed above)
GRANT OF CONSENT: In the event reasonable attempts to contact the parents or guardians have been unsuccessful, I hereby give my consent for
(1) the administration of any treatment deemed necessary by preferred Dr.
(2), or preferred Dentists or in the event designated Dr. or Dentist is not available, by another licensed physician or dentist; and
(2) the transfer of the child to preferred hospital or any hospital reasonably accessible. NOTE: This authorization does not cover major surgery unless the medical options of two other licensed physicians or dentists, concurring in necessity for such surgery are obtained BEFORE the surgery IS PERFORMED.

REFUSAL OF CONSENT: I do NOT give consent for emergency medical treatment of my child. In the event of illness or injury requiring emergency treatment, I wish that Lakes Youth Athletic Association to take no action, or perform the following actions.
Actions to be taken:


* Required Fields
__HTML__ print $html; } ########################################### # Modify player info on main registration ########################################### sub admin_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 %division_selected = get_division_data(); my @grades = get_grades(); my @relationships = get_relationships(); 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(); 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
__HTML__ #foreach my $div_id (sort { $a <=> $b } keys %division_selected) { # $html .= "\n"; #} $male_selected = ""; $female_selected = ""; $yes_selected = ""; $no_selected = ""; $consent_yes = ""; $consent_no = ""; if($mod_player_info{"CONSENT"} eq "Yes"){ $consent_yes = "CHECKED"; }else{ $consent_no = "CHECKED"; } if($mod_player_info{"GENDER"} eq "male"){ $male_selected = "CHECKED"; }else{ $female_selected = "CHECKED"; } if($mod_player_info{"RETURNING"} eq "Yes"){ $yes_selected = "CHECKED"; }else{ $no_selected = "CHECKED"; } if($mod_player_info{"PLAY_UP"} eq "Yes"){ $play_up = "CHECKED"; }else{ $play_up = ""; } $html .= <<__HTML__; __HTML__ $html .= <<__HTML__;
Player Information
Player First Name*
Player Last Name*
Date of Birth*
Gender* Male Female
School Name
Current Grade Level*
Returning Player* Yes No
Request this Player to play up a League:
Guardian Information
Guardian 1 Name*
Guardian 1 Primary Phone* $phone_example
Guardian 1 Secondary Phone $phone_example
Guardian 1 Relationship*
Guardian 2 Name
Guardian 2 Primary Phone $phone_example
Guardian 2 Secondary Phone $phone_example
Guardian 2 Relationship
Emergency Contact Information
Emergency Contact Name*
Emergency Contact Primary Phone* $phone_example
Emergency Contact Secondary Phone $phone_example
Emergency Contact Relationship*
Medical Information
Preferred Doctor Name
Preferred Doctor Phone $phone_example
Preferred Dentist Name
Preferred Dentist Phone $phone_example
Preferred Hospital
Insurance Carrier
Policy Number
Medical History:
Allergies, Medications,
Special Condition, etc
GRANT OF CONSENT * (please select one for the player listed above)
GRANT OF CONSENT: In the event reasonable attempts to contact the parents or guardians have been unsuccessful, I hereby give my consent for
(1) the administration of any treatment deemed necessary by preferred Dr.
(2), or preferred Dentists or in the event designated Dr. or Dentist is not available, by another licensed physician or dentist; and
(2) the transfer of the child to preferred hospital or any hospital reasonably accessible. NOTE: This authorization does not cover major surgery unless the medical options of two other licensed physicians or dentists, concurring in necessity for such surgery are obtained BEFORE the surgery IS PERFORMED.

REFUSAL OF CONSENT: I do NOT give consent for emergency medical treatment of my child. In the event of illness or injury requiring emergency treatment, I wish that Lakes Youth Athletic Association to take no action, or perform the following actions.
Actions to be taken:


* Required Fields
__HTML__ print $html; } sub get_division_data{ my %division_selected = (); $division_selected{0}{"S"} = ""; $division_selected{1}{"S"} = ""; $division_selected{2}{"S"} = ""; $division_selected{3}{"S"} = ""; $division_selected{4}{"S"} = ""; $division_selected{5}{"S"} = ""; $division_selected{6}{"S"} = ""; $division_selected{7}{"S"} = ""; $division_selected{8}{"S"} = ""; $division_selected{9}{"S"} = ""; $division_selected{10}{"S"} = ""; $division_selected{11}{"S"} = ""; $division_selected{12}{"S"} = ""; $division_selected{13}{"S"} = ""; $division_selected{14}{"S"} = ""; $division_selected{15}{"S"} = ""; $division_selected{0}{"OPTION"} = "--Sport - League - Age(min-max)--"; $division_selected{1}{"OPTION"} = "Baseball - Bronco - 10-12"; $division_selected{2}{"OPTION"} = "Baseball - Colt - 15-16"; $division_selected{3}{"OPTION"} = "Baseball - Mustang - 8-10"; $division_selected{4}{"OPTION"} = "Baseball - Pinto - 6-8"; $division_selected{5}{"OPTION"} = "Baseball - Pony - 12-14"; $division_selected{6}{"OPTION"} = "Baseball - Travel 11 year old - 10-11"; $division_selected{7}{"OPTION"} = "Baseball - Travel 12 year old - 10-12"; $division_selected{8}{"OPTION"} = "Baseball - Travel 13 year old - 12-13"; $division_selected{9}{"OPTION"} = "Baseball - Travel 14 year old - 13-14"; $division_selected{10}{"OPTION"} = "Softball - Bronco - 10-12"; $division_selected{11}{"OPTION"} = "Softball - Colt - 14-17"; $division_selected{12}{"OPTION"} = "Softball - Mustang - 8-10"; $division_selected{13}{"OPTION"} = "Softball - Pinto - 6-8"; $division_selected{14}{"OPTION"} = "Softball - Pony - 12-14"; $division_selected{15}{"OPTION"} = "Softball - Travel 11 year old - 10-11"; $division_selected{0}{"COST"} = "0"; $division_selected{1}{"COST"} = "150"; $division_selected{2}{"COST"} = "175"; $division_selected{3}{"COST"} = "150"; $division_selected{4}{"COST"} = "150"; $division_selected{5}{"COST"} = "175"; $division_selected{6}{"COST"} = "270"; $division_selected{7}{"COST"} = "270"; $division_selected{8}{"COST"} = "270"; $division_selected{9}{"COST"} = "270"; $division_selected{10}{"COST"} = "150"; $division_selected{11}{"COST"} = "175"; $division_selected{12}{"COST"} = "150"; $division_selected{13}{"COST"} = "150"; $division_selected{14}{"COST"} = "175"; $division_selected{15}{"COST"} = "175"; return %division_selected; } sub convert_epoch_to_years{ my $age_epoch = shift; my $seconds_in_year = 60*60*24*365; my $age_in_years =sprintf("%.3f", $age_epoch/$seconds_in_year); return $age_in_years; } sub get_transaction_id{ my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Transaction_ID` FROM `TMP_TRANSACTION_ID` WHERE 1"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Transaction_ID); while($sth->fetch()) { $return_id = $Transaction_ID; } # disconnect from database $query = "UPDATE `TMP_TRANSACTION_ID` SET `Transaction_ID`=`Transaction_ID`+1 WHERE `Transaction_ID` = '$return_id'"; $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->finish(); $dbh->disconnect; return $return_id; } sub insert_tmp_paypal{ my $account_id = shift; my $player_id = shift; my $amount = shift; my $transaction_id = shift; my $date = get_date_time(); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "INSERT INTO `Reg_Paypal` (`Key`, `Account_ID`, `Player_ID`, `Amount`, `Transaction_ID`, `PP_Transaction_ID`, `Processed`, `Date`) VALUES ('', '$account_id', '$player_id', '$amount', '$transaction_id','0', '0', '$date')"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->finish(); $dbh->disconnect; } sub admin_get_pay_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 = "\n"; $user_table .= "\n"; #$user_table .= "\n"; 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"; #$pay_pal .= "\n"; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $base_cost = is_older_than_cutoff($player_info{$user_number}{"DOB"},$player_info{$user_number}{"GENDER"}); $division_id = $player_info{$user_number}{"DIVISION"}; $player_key = $player_info{$user_number}{"KEY"}; $amount_paid = $player_info{$user_number}{"PAID"}; ($tmp_adjustment_info, $player_adjustment) = get_adjustment_info($player_info{$user_number}{"LASTNAME"}, $player_info{$user_number}{"FIRSTNAME"}, $player_info{$user_number}{"KEY"}); $user_table .= "\n"; $user_table .= "\n"; if($num_players > 2){$fundraiser_fee = 0; $fundraiser_string = "";}else{$fundraiser_fee = 30; $fundraiser_string = "+ \$30 Fundraiser";} if($num_players > 1){$discount = 15; $discount_string = "-\$15 multiplayer discount";}else{$discount = 0;$discount_string = "";} $player_total = $base_cost + $fundraiser_fee - $discount + $player_adjustment; $amount_due = $player_total - $amount_paid ; $registration_string = "\$$base_cost Registration Fee"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; if($player_adjustment > 0){ $adjustment_string = "+ \$$player_adjustment Adjustment Fee"; }else{ $adjustment_string = ""; } #$amount_due = .02; if($by_check == 0){ insert_tmp_paypal($user_key, $player_key, $amount_due, $transaction_id); } $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal_count++; $total_cost = $amount_due + $total_cost; $paid = "No"; $user_table .= "\n"; } $user_table .= "\n"; $user_table .= "
Registered Players
NameRegistration FeeFundraiser FeeAdjustmentsMulti-Player
Discount
TotalPaidDue
NameDivisionRegistration FeeFundraiser FeeDiscountTotalPaid
$player_info{$user_number}{\"FIRSTNAME\"} $player_info{$user_number}{\"LASTNAME\"} $player_info{$user_number}{\"DOB\"}\$" . $base_cost . "\$$fundraiser_fee\$$player_adjustment-\$$discount\$$player_total\$$amount_paid\$$amount_due
TOTAL DUE: \$$total_cost
\n"; if($by_check != 1){ $user_table .= "\n"; #$partial_form = "\n"; $user_table .= ""; $user_table .= "\n"; $user_table .= "\n"; } $pay_pal .= "\n"; $pay_pal .= "\n"; #$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"; $pay_pal .= "\n"; if($by_check == 1){ $user_table .= "
In order to complete registration by check…

\n"; $user_table .= "  1. Please make the check payable to “LYAA” for the above amount.
\n"; $user_table .= "  2. Please mail the check to the following address…

\n"; $user_table .= "      LYAA
\n"; $user_table .= "      PO Box 296
\n"; $user_table .= "      Wauconda, IL 60084

\n"; $user_table .= "If you have any questions contact the board by leaving a message
at: (847) 604-0270.
\n"; $user_table .= "
\n"; #$partial_form = "\n"; $user_table .= ""; $user_table .= "\n"; $user_table .= "
\n
"; } return $user_table, $pay_pal; } sub get_pay_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; if($by_check == 0){ $transaction_id = get_transaction_id(); } my $user_table = "\n"; $user_table .= "\n"; #$user_table .= "\n"; 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"; #$pay_pal .= "\n"; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $base_cost = is_older_than_cutoff($player_info{$user_number}{"DOB"},$player_info{$user_number}{"GENDER"}); $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"; if($num_players > 2){$fundraiser_fee = 0; $fundraiser_string = "";}else{$fundraiser_fee = 30; $fundraiser_string = "+ \$30 Fundraiser";} if($num_players > 1){$discount = 15; $discount_string = "-\$15 multiplayer discount";}else{$discount = 0;$discount_string = "";} $player_total = $base_cost + $fundraiser_fee - $discount; $amount_due = $player_total - $amount_paid; $registration_string = "\$$base_cost Registration Fee"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; #$amount_due = .02; if($by_check == 0){ insert_tmp_paypal($user_key, $player_key, $amount_due, $transaction_id); } $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal_count++; $total_cost = $amount_due + $total_cost; $paid = "No"; $user_table .= "\n"; } $user_table .= "\n"; $user_table .= "
Registered Players
NameRegistration FeeFundraiser FeeMulti-Player
Discount
TotalPaidDue
NameDivisionRegistration FeeFundraiser FeeDiscountTotalPaid
$player_info{$user_number}{\"FIRSTNAME\"} $player_info{$user_number}{\"LASTNAME\"} $player_info{$user_number}{\"DOB\"}\$" . $base_cost . "\$$fundraiser_fee-\$$discount\$$player_total\$$amount_paid\$$amount_due
TOTAL DUE: \$$total_cost
\n"; if($by_check != 1){ $user_table .= "\n"; #$partial_form = "\n"; $user_table .= ""; $user_table .= "\n"; $user_table .= "\n"; } $pay_pal .= "\n"; $pay_pal .= "\n"; #$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"; $pay_pal .= "\n"; if($by_check == 1){ $user_table .= "
In order to complete registration by check…

\n"; $user_table .= "  1. Please make the check payable to “LYAA” for the above amount.
\n"; $user_table .= "  2. Please mail the check to the following address…

\n"; $user_table .= "      LYAA
\n"; $user_table .= "      PO Box 296
\n"; $user_table .= "      Wauconda, IL 60084

\n"; $user_table .= "If you have any questions contact the board by leaving a message
at: (847) 604-0270.
\n"; $user_table .= "
\n"; #$partial_form = "\n"; $user_table .= ""; $user_table .= "\n"; $user_table .= "
\n
"; } return $user_table, $pay_pal; } sub get_amount_to_deduct{ my $partial = shift; my $total_remaining_players = shift; my $total_running_cost = shift; my $max_deduction = shift; my $player_min = shift; my $partial_remaining = $partial - $total_running_cost; my $deduction = 0; my $amount_to_deduct = 0; if($total_remaining_players > 0){ $amount_to_deduct = sprintf("%.0d", ($partial_remaining/$total_remaining_players)); $rounded_total = $amount_to_deduct * $total_remaining_players; if($rounded_total > $partial_remaining){ $deduction = $amount_to_deduct - ($rounded_total - $partial_remaining); }elsif($rounded_total < $partial){ $deduction = $amount_to_deduct + ($partial_remaining - $rounded_total); }else{ $deduction = $amount_to_deduct; } }else{ $deduction = 0; } print "ATD: $amount_to_deduct RT: $rounded_total PM: $partial_remaining - TMP: $total_remaining_players - D:$deduction - MAX:$max_deduction
\n"; ### If the deduction is greater than the max deduction set to max ### Also if the deduction is greater than max deduction, set it to max ### in order to lower the total. if(($deduction > $max_deduction)||($deduction >= $player_min)){ $deduction = $max_deduction; if($deduction > $partial_remaining){$deduction = $partial_remaining;} } if($deduction < 0){ $deduction = 0; } $deduction = sprintf("%0d", $deduction); return $deduction; } sub admin_get_partial_pay_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 = "\n"; $user_table .= "\n"; #$user_table .= "\n"; 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"; $pay_pal .= "\n"; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $base_cost = is_older_than_cutoff($player_info{$user_number}{"DOB"},$player_info{$user_number}{"GENDER"}); $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"; ($tmp_adjustment_info, $player_adjustment) = get_adjustment_info($player_info{$user_number}{"LASTNAME"}, $player_info{$user_number}{"FIRSTNAME"}, $player_info{$user_number}{"KEY"}); if($num_players > 2){$fundraiser_fee = 0; $fundraiser_string = "";}else{$fundraiser_fee = 30; $fundraiser_string = "+ \$30 Fundraiser";} if($num_players > 1){$discount = 15; $discount_string = "-\$15 multiplayer discount";}else{$discount = 0;$discount_string = "";} $player_total = $base_cost + $fundraiser_fee - $discount + $player_adjustment; $max_pay = $player_total - $amount_paid; my $amount_to_deduct = get_amount_to_deduct($partial, ($total_num_players - $num_players + 1), $total_cost, $max_pay, $player_min); $remaining_balance = $player_total - $amount_to_deduct - $amount_paid; $amount_due = $player_total - $amount_paid ; if($player_adjustment != 0){ $adjustment_string = "+ \$$player_adjustment Adjustment Fee"; }else{ $adjustment_string = ""; } #$amount_to_deduct = .02; insert_tmp_paypal($user_key, $player_key, $amount_to_deduct, $transaction_id); $registration_string = "\$$base_cost Registration Fee"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; #$user_table .= "\n"; #$user_table .= "\n"; $balance = $balance + $amount_due; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal_count++; $total_cost = $amount_to_deduct + $total_cost; $paid = "No"; } $total_remaining = $balance - $total_cost; if($by_check == 2){ $user_table .= "\n"; $user_table .= "\n"; }else{ $user_table .= "\n"; } if($by_check != 1){ if($by_check == 2){ $user_table .= "\n"; $user_table .= "\n"; }else{ $user_table .= "\n"; } #$partial_form = "\n"; if($by_check == 2){ $this_action = "admin_partial"; }else{ $this_action = "admin_verify_partial"; } $user_table .= ""; $user_table .= "\n"; $user_table .= "\n"; } $user_table .= "
Registered Players
NameRegistration FeeFundraiser FeeAdjustmentsMulti-Player
Discount
TotalPaidDue
NameDivisionRegistration FeeFundraiser FeeDiscountTotalPaid
$player_info{$user_number}{\"FIRSTNAME\"} $player_info{$user_number}{\"LASTNAME\"} \$" . $base_cost . "\$$fundraiser_fee\$$player_adjustment-\$$discount\$$player_total-\$$amount_paid\$$amount_due-\$$amount_to_deduct\$$remaining_balance
Balance: \$$balance
TOTAL REMAINING After Payment: \$$total_remaining
Balance: \$$balance
Confirm Amount to Pay Now: \$$total_cost
Enter the Partial Amount You Want to Pay: \$
\n"; $pay_pal .= "\n"; #$pay_pal .= "\n"; if($by_check == 2){ $pay_pal .= "\n"; }else{ #$pay_pal .= "\n"; } #$pay_pal .= "
Make sure to Update the Payment before Paying with Credit Card
\n"; #$pay_pal .= "\n"; $pay_pal .= "
\n"; if($by_check == 1){ $user_table .= "
In order to complete registration by check…

\n"; $user_table .= "  1. Please make the check payable to “LYAA” for the above amount.
\n"; $user_table .= "  2. Please mail the check to the following address…

\n"; $user_table .= "      LYAA
\n"; $user_table .= "      PO Box 296
\n"; $user_table .= "      Wauconda, IL 60084

\n"; $user_table .= "If you have any questions contact the board by leaving a message
at: (847) 604-0270.\n"; } return $user_table, $pay_pal; } sub get_partial_pay_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 = "\n"; $user_table .= "\n"; #$user_table .= "\n"; 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"; $pay_pal .= "\n"; foreach my $user_number (sort {$a <=> $b} (keys %player_info)){ $num_players++; my $base_cost = is_older_than_cutoff($player_info{$user_number}{"DOB"},$player_info{$user_number}{"GENDER"}); $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"; if($num_players > 2){$fundraiser_fee = 0; $fundraiser_string = "";}else{$fundraiser_fee = 30; $fundraiser_string = "+ \$30 Fundraiser";} if($num_players > 1){$discount = 15; $discount_string = "-\$15 multiplayer discount";}else{$discount = 0;$discount_string = "";} $player_total = $base_cost + $fundraiser_fee - $discount; $max_pay = $player_total - $amount_paid; my $amount_to_deduct = get_amount_to_deduct($partial, ($total_num_players - $num_players + 1), $total_cost, $max_pay, $player_min); $remaining_balance = $player_total - $amount_to_deduct - $amount_paid; $amount_due = $player_total - $amount_paid; #$amount_to_deduct = .02; insert_tmp_paypal($user_key, $player_key, $amount_to_deduct, $transaction_id); $registration_string = "\$$base_cost Registration Fee"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; $user_table .= "\n"; #$user_table .= "\n"; #$user_table .= "\n"; $balance = $balance + $amount_due; $pay_pal .= "\n"; $pay_pal .= "\n"; $pay_pal_count++; $total_cost = $amount_to_deduct + $total_cost; $paid = "No"; } $total_remaining = $balance - $total_cost; if($by_check == 2){ $user_table .= "\n"; $user_table .= "\n"; }else{ $user_table .= "\n"; } if($by_check != 1){ if($by_check == 2){ $user_table .= "\n"; $user_table .= "\n"; }else{ $user_table .= "\n"; } #$partial_form = "\n"; if($by_check == 2){ $this_action = "partial"; }else{ $this_action = "verify_partial"; } $user_table .= ""; $user_table .= "\n"; $user_table .= "\n"; } $user_table .= "
Registered Players
NameRegistration FeeFundraiser FeeMulti-Player
Discount
TotalPaidDue
NameDivisionRegistration FeeFundraiser FeeDiscountTotalPaid
$player_info{$user_number}{\"FIRSTNAME\"} $player_info{$user_number}{\"LASTNAME\"} \$" . $base_cost . "\$$fundraiser_fee-\$$discount\$$player_total-\$$amount_paid\$$amount_due-\$$amount_to_deduct\$$remaining_balance
Balance: \$$balance
TOTAL REMAINING After Payment: \$$total_remaining
Balance: \$$balance
Confirm Amount to Pay Now: \$$total_cost
Enter the Partial Amount You Want to Pay: \$
\n"; $pay_pal .= "\n"; #$pay_pal .= "\n"; if($by_check == 2){ $pay_pal .= "\n"; }else{ #$pay_pal .= "\n"; } #$pay_pal .= "
Make sure to Update the Payment before Paying with Credit Card
\n"; #$pay_pal .= "\n"; $pay_pal .= "
\n"; if($by_check == 1){ $user_table .= ""; $html .= ""; $html .= ""; } $sth->finish(); $dbh->disconnect; print $html; } sub get_sender_data{ my $user_id = shift; my $dbh = get_dbh(); my $query = "SELECT a.`Key`, b.`Comm_Email_ID`, b.`Comm_Email_Address_ID`, b.`Email_Bounce`, c.`Comm_Email_Address` FROM `Comm_Email_Message` a, `Comm_Email_Link` b, `Comm_Email_Address` c WHERE a.`From_ID` = '$user_id' AND a.`Key` = b.`Comm_Email_ID` AND b.`Comm_Email_Address_ID` = c.`Key`"; my $sth = $dbh->prepare($query); $sth->execute(); #print "QUERY: $query
\n"; my %return_hash; while ( my $results = $sth->fetchrow_hashref ){ if(defined($return_hash{$results->{Key}}{"TO"})){ $return_hash{$results->{Key}}{"TO"} .= "," . $results->{Comm_Email_Address}; $return_hash{$results->{Key}}{"COUNT"}++; if($results->{Email_Bounce} == 1){ $return_hash{$results->{Key}}{"BOUNCE"}++; } }else{ $return_hash{$results->{Key}}{"TO"} = $results->{Comm_Email_Address}; $return_hash{$results->{Key}}{"COUNT"} = 1; if($results->{Email_Bounce} == 1){ $return_hash{$results->{Key}}{"BOUNCE"} = 1; }else{ $return_hash{$results->{Key}}{"BOUNCE"} = 0; } } } $sth->finish(); $dbh->disconnect; return %return_hash; } 1;
In order to complete registration by check…

\n"; $user_table .= "  1. Please make the check payable to “LYAA” for the above amount.
\n"; $user_table .= "  2. Please mail the check to the following address…

\n"; $user_table .= "      LYAA
\n"; $user_table .= "      PO Box 296
\n"; $user_table .= "      Wauconda, IL 60084

\n"; $user_table .= "If you have any questions contact the board by leaving a message
at: (847) 604-0270.\n"; } return $user_table, $pay_pal; } sub get_player_id_from_cookie{ my $session_id = get_cookie(); my $login = get_login_from_session($session_id); return $login; } ################################################################ ### Update adjustemnt ################################################################ sub insert_walkin_adjustment{ my $player_key = shift; my $amount = shift; my $check_notes = "Walk In"; 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 ('', '$account_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; } sub check_for_first_player_for_user{ my $user_key = shift; my $dbh = get_dbh(); my $query = "SELECT `Key` FROM `Account_Player_Info` WHERE `Account_ID` = '$user_key'"; #print "$query
\n"; my $sth = $dbh->prepare($query); my $first_player = 1; $sth->execute(); $sth->bind_columns(\$Key); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. ################################################################ while($sth->fetch()) { $first_player = 0; } return $first_player; } ################################################################ ### Update user info in db ################################################################ sub admin_update_account{ $lname = get_param('lname'); $fname = get_param('fname'); $email = param('email'); $ad1 = get_param('ad1'); $ad2 = get_param('ad2'); $city = get_param('city'); $state = param('state'); $zip = param('zip'); $phone = get_param('phone'); $mphone = get_param('mphone'); my $dbh = get_dbh(); my $query = "UPDATE `Account_Info` a, `Account_Extra_Info` b SET a.`Firstname`='$fname', a.`Lastname`='$lname', a.`Home_Phone`='$phone', a.`Mobile_Phone`='$mphone', a.`Zip_Code`='$zip', b.`Address1`='$ad1' , b.`Address2`='$ad2' , b.`City`='$city', b.`State`='$state' WHERE a.`email`='$email' AND a.`Key` = b.`Account_ID`;"; #print "Q: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $email; } ################################################################ ### Update user info in db ################################################################ sub update_account{ $lname = get_param('lname'); $fname = get_param('fname'); $email = param('email'); $ad1 = get_param('ad1'); $ad2 = get_param('ad2'); $city = get_param('city'); $state = param('state'); $zip = param('zip'); $phone = get_param('phone'); $mphone = get_param('mphone'); my $dbh = get_dbh(); my $query = "UPDATE `Account_Info` a, `Account_Extra_Info` b SET a.`Firstname`='$fname', a.`Lastname`='$lname', a.`Home_Phone`='$phone', a.`Mobile_Phone`='$mphone', a.`Zip_Code`='$zip', b.`Address1`='$ad1' , b.`Address2`='$ad2' , b.`City`='$city', b.`State`='$state' WHERE a.`email`='$email' AND a.`Key` = b.`Account_ID`;"; #print "Q: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; return $email; } ################################################################ ### Print verify user registration ################################################################ sub admin_print_verify_account_info{ my $email = shift; my %user_info = get_account_info_by_email($email); $active_id{"create"} = "id=current"; print "
\n"; #print_steps(); print_reg_style(); print "
\n"; my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2: Verify Account Owner Information
Please verify your account information for the primary person responsible for payment and under whom the participants will be listed.

Account Holder Information
First Name  $user_info{"FIRSTNAME"}
Last Name  $user_info{"LASTNAME"}
Email  $user_info{"EMAIL"}
Address 1  $user_info{"ADDRESS1"}
Address 2  $user_info{"ADDRESS2"}
City  $user_info{"CITY"}
State  $user_info{"STATE"}
Zip  $user_info{"ZIP_CODE"}
Phone  $user_info{"HOMEPHONE"}
Mobile Phone  $user_info{"MOBILE_PHONE"}

The above information is correct...

The above information is not correct...
__HTML__ print $html; } ################################################################ ### Print verify user registration ################################################################ sub print_verify_account_info{ my $email = shift; my %user_info = get_account_info_by_email($email); $active_id{"create"} = "id=current"; print_steps(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2: Verify Account Owner Information
Please verify your account information for the primary person responsible for payment and under whom the participants will be listed.

Account Holder Information
First Name  $user_info{"FIRSTNAME"}
Last Name  $user_info{"LASTNAME"}
Email  $user_info{"EMAIL"}
Address 1  $user_info{"ADDRESS1"}
Address 2  $user_info{"ADDRESS2"}
City  $user_info{"CITY"}
State  $user_info{"STATE"}
Zip  $user_info{"ZIP_CODE"}
Phone  $user_info{"HOMEPHONE"}
Mobile Phone  $user_info{"MOBILE_PHONE"}

The above information is correct...

The above information is not correct...
__HTML__ print $html; } sub get_grades{ my @grades = ("K",1,2,3,4,5,6,7,8,9,10,11,12); return @grades; } sub get_relationships{ my @relationships = ("Father", "Mother", "Legal Guardian", "Grandparent", "Other"); return @relationships; } ################################################################ ### Get the HTML player table show in upper right corner ################################################################ sub get_player_table_old{ 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
NameEditRemovePaid
$player_info{$user_number}{\"FIRSTNAME\"} $player_info{$user_number}{\"LASTNAME\"}\$$amount_paid
\n"; return $user_table, $player_number; } sub get_submit_to_pay{ my $user_key = shift; my $return_val = <<__HTML__;
Register additional players below or
proceed to
__HTML__ return $return_val; } sub get_admin_submit_to_pay{ my $user_key = shift; my $return_val = <<__HTML__;
Register additional players below or
proceed to
__HTML__ return $return_val; } ################################################################ ### Creates new user account in db ################################################################ sub admin_createaccount{ $lname = get_param('lname'); $fname = get_param('fname'); $email = get_param('email'); $ad1 = get_param('ad1'); $ad2 = get_param('ad2'); $city = get_param('city'); $state = param('state'); $zip = get_param('zip'); $phone = get_param('phone'); $mphone = get_param('mphone'); $pw1 = get_param('pw1'); $pw2 = get_param('pw2'); my $dbh = get_dbh(); my $query = "INSERT INTO `Account_Info` ( `Key` , `Login` , `Password` , `email` , `League_ID`, `Last_Access`, `Last_Access_ID`, `Firstname`, `Lastname`, `Title`, `Home_Phone`, `Work_Phone`, `Mobile_Phone`, `Zip_Code`, `Token`) VALUES ('', '$email', '$pw1', '$email', '', '', '', '$fname', '$lname', 'USER', '$phone', '', '$mphone', '$zip', '');"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; my $new_key = check_for_account($email); ########################################### # Add extra Info ########################################### $dbh = get_dbh(); my $query2 = "INSERT INTO `Account_Extra_Info` ( `Key` , `Account_ID` , `Address1` , `Address2` , `City`, `State`)VALUES ('', '$new_key', '$ad1', '$ad2', '$city', '$state');"; #print "Q2:$query2
\n"; $sth = $dbh->prepare($query2); $sth->execute(); $sth->finish(); ########################################### # Link Account to Org ########################################### $dbh = get_dbh(); my $query3 = "INSERT INTO `Account_Org_Reg_Link` ( `Key` , `Account_ID` , `Org_ID`)VALUES ('', '$new_key', '$org_id');"; #print "Q2:$query2
\n"; $sth = $dbh->prepare($query3); $sth->execute(); $sth->finish(); $dbh->disconnect; #check_reg_login($email, "$pw1"); #remove_temp_password($email); return $new_key; } ################################################################ ### Remove Temp Password from db ################################################################ sub remove_temp_password{ my $email = shift; ########################################### # Link Account to Org ########################################### my $dbh = get_dbh(); my $query = "DELETE FROM `Account_TMP_Password` WHERE `EMAIL`='$email' LIMIT 1;"; #print "Q2:$query2
\n"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->finish(); $dbh->disconnect; } ################################################################ ### Check to see if the user is logged in ################################################################ sub check_reg_login{ my $user = shift; my $pass = shift; my $league_id = shift; my $success = 0; my $session = ""; my $session_id = get_cookie(); if(!(defined($user))){$user = "";} if(!(defined($pass))){$pass = "";} if(!(defined($league_id))){$league_id = "";$user = "", $pass = "";} if(($user ne "") && ($pass ne "")){ $session_id = ""; } my $dbh = get_dbh(); ################################################################ # Check to see if there is a valid cookie ################################################################ if($session_id eq ""){ ################################################################ # If not a valid cookie, check the to see if the user/pass # combination is correct ################################################################ if(($user ne "") && ($pass ne "")){ print "\n"; $session_id = ""; my $query = "SELECT * FROM `Account_Info` WHERE (`Login` = '$user' OR `email` = '$user') AND `Password` = '$pass'"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Login, \$Password, \$email, \$League_ID, \$Last_Access, \$Last_Access_ID, \$Firstname, \$Lastname, \$Title, \$Home_Phone, \$Work_Phone, \$Zip_Code, \$Token); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. ################################################################ while($sth->fetch()) { $success = 1; } ################################################################ # Login failed because incorrect Login or password ################################################################ if($success == 0){ print "

Invalid ID or Password.
Please try again.
\n"; $session_id = ""; #print "\n"; }else{ $current_date = get_date_time(); $session_id = generate_random_string(15); $update = "UPDATE `Account_Info` SET `Last_Access`='$current_date', `Last_Access_ID`='$session_id' WHERE `Key` = $Key;"; ##print "QUERY: $update
\n"; $sth = $dbh->prepare($update); $sth->execute(); $sth->finish(); print <<__HTML__; __HTML__ } }else{ ################################################################ # Login failed because no Login or password # Could be first time loggin in. ################################################################ $session_id = ""; } }else{ #print "\n"; ################################################################ # Query DB to verify Session ################################################################ $query = "SELECT * FROM `Account_Info` WHERE `Last_Access_ID` = '$session_id'"; $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Login, \$Password, \$email, \$League_ID, \$Last_Access, \$Last_Access_ID, \$Firstname, \$Lastname, \$Title, \$Home_Phone, \$Work_Phone, \$Mobile_Phone, \$Zip_Code, \$Token); ################################################################ # Loop through what the db returned, if there is somthing there # it assumes success. ################################################################ while($sth->fetch()) { $success = 1; } ################################################################ # If we get to this point. The cookie is invalid at least for # this league. ################################################################ if($success == 0){ #print "

Your Session has expired,
Please login again.
\n"; print "\n"; $session_id = ""; }else{ ################################################################ # Update DB to keep session active ################################################################ $current_date = get_date_time(); $update = "UPDATE `Account_Info` SET `Last_Access`='$current_date' WHERE `Key` = $Key;"; ##print "QUERY: $update
\n"; $sth = $dbh->prepare($update); $sth->execute(); $sth->finish(); ################################################################ # Update Cookie to keep session active ################################################################ print <<__HTML__; __HTML__ } } ################################################################ # Close DB connection ################################################################ # disconnect from database $dbh->disconnect; return $session_id; } sub admin_print_update_account{ my $email = shift; my %user_info = get_account_info_by_email($email); $active_id{"create"} = "id=current"; print "
\n"; #print_steps(); print_reg_style(); print "
\n"; my $email_validation = get_email_validation(); my $phone_validation = get_phone_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2 : Modify Account
Please enter account information for the primary person responsible for payment and under whom the participants will be listed.

Modify Account Owner Information
*First Name
*Last Name
*Email
*Address 1
Address 2
*City
*State
*Zip
*Phone $phone_example
Mobile Phone $phone_example


* Required Fields
__HTML__ print $html; } sub print_update_account{ my $email = shift; my %user_info = get_account_info_by_email($email); $active_id{"create"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $phone_validation = get_phone_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2 : Modify Account
Please enter account information for the primary person responsible for payment and under whom the participants will be listed.

Modify Account Owner Information
*First Name
*Last Name
*Email
*Address 1
Address 2
*City
*State
*Zip
*Phone $phone_example
Mobile Phone $phone_example


* Required Fields
__HTML__ print $html; } sub admin_print_create_account{ $active_id{"create"} = "id=current"; my @states = get_states(); print "
\n"; #print_steps(); print_reg_style(); print "
\n"; my $email_validation = get_email_validation(); my $phone_validation = get_phone_validation(); my $zip_validation = get_zip_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2 : Create Account
Please enter account information for the primary person responsible for payment and under whom the participants will be listed.

Enter Account Owner Information
*First Name
*Last Name
*Email
*Address 1
Address 2
*City
*State
*Zip
*Phone $phone_example
Mobile Phone $phone_example
*Create New Password
*Re-type Password


* Required Fields
__HTML__ print $html; } sub print_create_account{ $active_id{"create"} = "id=current"; my @states = get_states(); print_steps(); my $email_validation = get_email_validation(); my $phone_validation = get_phone_validation(); my $zip_validation = get_zip_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 2 : Create Account
Please enter account information for the primary person responsible for payment and under whom the participants will be listed.

Enter Account Owner Information
*First Name
*Last Name
*Email
*Address 1
Address 2
*City
*State
*Zip
*Phone $phone_example
Mobile Phone $phone_example
*Create New Password
*Re-type Password


* Required Fields
__HTML__ print $html; } ############################################ # Step 1. login or create new account ############################################ sub print_admin_login{ my $msg = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print "
\n"; #print_steps(); print_reg_style(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
$alert
Registration Admin Login

Admin Account
Email
Password
__HTML__ print $html; } sub format_alert{ $msg = shift; if($msg ne ""){ $alert =<<__HTML__;
$msg

__HTML__ }else{ $alert = ""; } return $alert; } sub get_email_by_x{ my $x = shift; my $return_email = ""; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Email` FROM `Account_TMP_Password` WHERE `Tmp_String` = '$x';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Email); while($sth->fetch()) { $return_email = $Email; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_email; } sub print_temp_pw_login{ #### Does not send email my $alert = shift; $active_id{"login"} = "id=current"; my $x = param('x'); my $show_login = 0; if(!(defined($x))){ $x = ""; } #my $alert = ""; if(!(defined($newemail))){ $newemail = get_email_by_x($x); if($newemail eq ""){ $alert = "Your temporary password is no longer active, please try again."; $show_login = 1; } } if($show_login == 0){ $alert = format_alert($alert); print_steps(); my $html = <<__HTML__; $alert
Step 1: Verify Email
Please use your temporary password to log in.

Existing Account
Email
Temp Password
 
__HTML__ print $html; }else{ print_reg_login($alert); } } ############################################ # Step 1. Admin Home ############################################ sub print_admin_home{ my $msg = shift; my $access_level = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print "
\n"; #print_steps(); print_reg_style(); print "
\n"; my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__; $alert
Registration Admin Menu

Registration Name: $reg_year
Registration Management
__HTML__ if($access_level >= 3){ #### Manage Registrants $html .= <<__HTML__;
Manage Registrants and Payments
__HTML__ } if($access_level >= 2){ #### Manage Assignments if(($require_confirmation == 1) || ($league_assign_on == 1)){ $html .= <<__HTML__;
Manage Registrant Status/Assignments
__HTML__ } } if($access_level >= 3){ #### Walk in $html .= <<__HTML__;
Enter New Mail-in or Walk-in Registrant
__HTML__ } $html .= <<__HTML__;
Registration Reports
__HTML__ if($access_level >= 3){ #### Manage Registrants if($reg_year eq 'psc2010'){ $html .= "Export All Registration Data to Excel\n"; }elsif($reg_year eq 'psc2011'){ $html .= "Export All Registration Data to Excel\n"; }else{ $html .= "Export All Registration Data to Excel\n"; } } if($access_level >= 2){ #### Manage Registrants if($org_id == 167){ if($reg_year eq 'psc2010'){ $html .= "
Export Team Rosters to Excel\n"; }elsif($reg_year eq 'psc2011'){ $html .= "
Export Team Rosters to Excel\n"; }else{ $html .= "
Export Team Rosters to Excel\n"; } } } $html .= <<__HTML__;
__HTML__ print $html; } ############################################ # Step 1. (Admin Account Creation) ############################################ sub admin_print_create_user{ my $msg = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print "
\n"; #print_steps(); print_reg_style(); print "
\n"; my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__; $alert
Step 1 : Enter New Registrant Account (Mail-in or Walk-in Registration)
This is to be used by the Registration Admin to enter a mail-in or walk-in registration. Please enter the email address for the new registrant below.

If the registrant does not have an email address, please enter a fake email address using their first and last name as follows… firstname.\@your_domain.org (no spaces, special characters, all lower case, etc.)

New Account
Email

__HTML__ print $html; } ############################################ # Step 1. login or create new account ############################################ sub print_reg_login{ my $msg = shift; if($msg ne ""){ $alert =<<__HTML__
$msg

__HTML__ } $active_id{"login"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__; $alert
Step 1: User Login
Please login or create a new account. Your account is used to register your children for programs as well as tracking the status of your registration.

New Account
Email

Existing Account
Email
Password
Forget Password? Click Here
__HTML__ print $html; } ############################################ # This is for when the account already # exist, prompt for a new account ############################################ sub print_create_new_account_duplicate_email{ $active_id{"login"} = "id=current"; print_steps(); my $email_validation = get_email_validation(); my $jscript = <<__JSCRIPT__; __JSCRIPT__ print $jscript; my $html = <<__HTML__;
Step 1: User Login
There is already an account created for that email, please login or try a different account name.

New Account
Email

Existing Account
Email
Password
Forget Password? Click Here
__HTML__ print $html; } ############################################ # Get States ############################################ sub get_states{ my @states=("AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"); return @states; } ############################################ # Get player info ############################################ sub get_player_info_older{ my $user_key = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT * FROM `Account_Player_Info` 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, \$Account_ID, \$Firstname, \$Lastname, \$Division_Pref, \$Shirt_Size, \$Pant_Size, \$Hat_Size, \$Shoe_Size, \$Jersey_Pref, \$DOB, \$Gender, \$School_Name, \$Grade, \$Age, \$Height, \$Weight, \$E_Contact_Name, \$E_Contact_Phone, \$E_Contact_SPhone, \$E_Contact_Relationship, \$G_Contact_Phone, \$G_Contact_SPhone, \$G_Contact_Name, \$G_Contact_Relationship, \$OG_Contact_Phone, \$OG_Contact_SPhone, \$OG_Contact_Name, \$OG_Contact_Relationship, \$Preferred_Doc_Name, \$Preferred_Doc_Number, \$Preferred_Dentist_Name, \$Preferred_Dentist_Number, \$Preferred_Hospital, \$Insurance_Carrier, \$Policy_Number, \$Medical_History, \$Returning_Player, \$Paid, \$Active, \$Consent, \$Consent_Actions, \$Play_Up); $user_number = 1; while($sth->fetch()) { $return_hash{$user_number}{"KEY"} = $Key; $return_hash{$user_number}{"FIRSTNAME"} = $Firstname; $return_hash{$user_number}{"LASTNAME"} = $Lastname; $return_hash{$user_number}{"DIVISION"} = $Division_Pref; $return_hash{$user_number}{"SHIRT_SIZE"} = $Shirt_Size; $return_hash{$user_number}{"PANT_SIZE"} = $Pant_Size; $return_hash{$user_number}{"HAT_SIZE"} = $Hat_Size; $return_hash{$user_number}{"SHOE_SIZE"} = $Shoe_Size; $return_hash{$user_number}{"JERSEY_PREF"} = $Jersey_Pref; $return_hash{$user_number}{"DOB"} = $DOB; $return_hash{$user_number}{"GENDER"} = $Gender; $return_hash{$user_number}{"SNAME"} = $School_Name; $return_hash{$user_number}{"GRADE"} = $Grade; $return_hash{$user_number}{"AGE"} = $Age; $return_hash{$user_number}{"HEIGHT"} = $Height; $return_hash{$user_number}{"WEIGHT"} = $Weight; $return_hash{$user_number}{"E_CONTACT_PHONE"} = $E_Contact_Phone; $return_hash{$user_number}{"E_CONTACT_SPHONE"} = $E_Contact_SPhone; $return_hash{$user_number}{"E_CONTACT_NAME"} = $E_Contact_Name; $return_hash{$user_number}{"E_CONTACT_REL"} = $E_Contact_Relationship; $return_hash{$user_number}{"G_CONTACT_PHONE"} = $G_Contact_Phone; $return_hash{$user_number}{"G_CONTACT_SPHONE"} = $G_Contact_SPhone; $return_hash{$user_number}{"G_CONTACT_NAME"} = $G_Contact_Name; $return_hash{$user_number}{"G_CONTACT_REL"} = $G_Contact_Relationship; $return_hash{$user_number}{"OG_CONTACT_PHONE"} = $OG_Contact_Phone; $return_hash{$user_number}{"OG_CONTACT_SPHONE"}= $OG_Contact_SPhone; $return_hash{$user_number}{"OG_CONTACT_NAME"} = $OG_Contact_Name; $return_hash{$user_number}{"OG_CONTACT_REL"} = $OG_Contact_Relationship; $return_hash{$user_number}{"PREF_DOC_NAME"} = $Preferred_Doc_Name; $return_hash{$user_number}{"PREF_DOC_NUMB"} = $Preferred_Doc_Number; $return_hash{$user_number}{"PREF_DENT_NAME"} = $Preferred_Dentist_Name; $return_hash{$user_number}{"PREF_DENT_NUMB"} = $Preferred_Dentist_Number; $return_hash{$user_number}{"PREF_HOSPITAL"} = $Preferred_Hospital; $return_hash{$user_number}{"INSURANCE"} = $Insurance_Carrier; $return_hash{$user_number}{"POLICY"} = $Policy_Number; $return_hash{$user_number}{"MEDICAL"} = $Medical_History; $return_hash{$user_number}{"RETURNING"} = $Returning_Player; $return_hash{$user_number}{"PAID"} = $Paid; $return_hash{$user_number}{"ACTIVE"} = $Active; $return_hash{$user_number}{"CONSENT"} = $Consent; $return_hash{$user_number}{"ACTIONSTO"} = $Consent_Actions; $return_hash{$user_number}{"PLAY_UP"} = $Play_Up; $user_number++; } # disconnect from database $dbh->disconnect; $sth->finish(); return %return_hash; } ############################################ # Get player info2, this one returns the # Key as the main index ############################################ sub get_player_info2{ my $user_key = shift; my $return_hash = 0; my %return_hash = (); my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT * FROM `Account_Player_Info` 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, \$Account_ID, \$Firstname, \$Lastname, \$Division_Pref, \$Shirt_Size, \$Pant_Size, \$Hat_Size, \$Shoe_Size, \$Jersey_Pref, \$DOB, \$Gender, \$School_Name, \$Grade, \$Age, \$Height, \$Weight, \$E_Contact_Name, \$E_Contact_Phone, \$E_Contact_SPhone, \$E_Contact_Relationship, \$G_Contact_Phone, \$G_Contact_SPhone, \$G_Contact_Name, \$G_Contact_Relationship, \$OG_Contact_Phone, \$OG_Contact_SPhone, \$OG_Contact_Name, \$OG_Contact_Relationship, \$Preferred_Doc_Name, \$Preferred_Doc_Number, \$Preferred_Dentist_Name, \$Preferred_Dentist_Number, \$Preferred_Hospital, \$Insurance_Carrier, \$Policy_Number, \$Medical_History, \$Returning_Player, \$Paid, \$Active, \$Consent, \$Consent_Actions, \$Play_Up); $user_number = 1; while($sth->fetch()) { $return_hash{$Key}{"KEY"} = $Key; $return_hash{$Key}{"FIRSTNAME"} = $Firstname; $return_hash{$Key}{"LASTNAME"} = $Lastname; $return_hash{$Key}{"DIVISION"} = $Division_Pref; $return_hash{$Key}{"SHIRT_SIZE"} = $Shirt_Size; $return_hash{$Key}{"PANT_SIZE"} = $Pant_Size; $return_hash{$Key}{"HAT_SIZE"} = $Hat_Size; $return_hash{$Key}{"SHOE_SIZE"} = $Shoe_Size; $return_hash{$Key}{"JERSEY_PREF"} = $Jersey_Pref; $return_hash{$Key}{"DOB"} = $DOB; $return_hash{$Key}{"GENDER"} = $Gender; $return_hash{$Key}{"SNAME"} = $School_Name; $return_hash{$Key}{"GRADE"} = $Grade; $return_hash{$Key}{"AGE"} = $Age; $return_hash{$Key}{"HEIGHT"} = $Height; $return_hash{$Key}{"WEIGHT"} = $Weight; $return_hash{$Key}{"E_CONTACT_PHONE"} = $E_Contact_Phone; $return_hash{$Key}{"E_CONTACT_SPHONE"} = $E_Contact_SPhone; $return_hash{$Key}{"E_CONTACT_NAME"} = $E_Contact_Name; $return_hash{$Key}{"E_CONTACT_REL"} = $E_Contact_Relationship; $return_hash{$Key}{"G_CONTACT_PHONE"} = $G_Contact_Phone; $return_hash{$Key}{"G_CONTACT_SPHONE"} = $G_Contact_SPhone; $return_hash{$Key}{"G_CONTACT_NAME"} = $G_Contact_Name; $return_hash{$Key}{"G_CONTACT_REL"} = $G_Contact_Relationship; $return_hash{$Key}{"OG_CONTACT_PHONE"} = $OG_Contact_Phone; $return_hash{$Key}{"OG_CONTACT_SPHONE"}= $OG_Contact_SPhone; $return_hash{$Key}{"OG_CONTACT_NAME"} = $OG_Contact_Name; $return_hash{$Key}{"OG_CONTACT_REL"} = $OG_Contact_Relationship; $return_hash{$Key}{"PREF_DOC_NAME"} = $Preferred_Doc_Name; $return_hash{$Key}{"PREF_DOC_NUMB"} = $Preferred_Doc_Number; $return_hash{$Key}{"PREF_DENT_NAME"} = $Preferred_Dentist_Name; $return_hash{$Key}{"PREF_DENT_NUMB"} = $Preferred_Dentist_Number; $return_hash{$Key}{"PREF_HOSPITAL"} = $Preferred_Hospital; $return_hash{$Key}{"INSURANCE"} = $Insurance_Carrier; $return_hash{$Key}{"POLICY"} = $Policy_Number; $return_hash{$Key}{"MEDICAL"} = $Medical_History; $return_hash{$Key}{"RETURNING"} = $Returning_Player; $return_hash{$Key}{"PAID"} = $Paid; $return_hash{$Key}{"ACTIVE"} = $Active; $return_hash{$Key}{"CONSENT"} = $Consent; $return_hash{$Key}{"ACTIONSTO"} = $Consent_Actions; $return_hash{$Key}{"PLAY_UP"} = $Play_Up; $user_number++; } # disconnect from database $dbh->disconnect; $sth->finish(); return %return_hash; } ############################################ # Get pw info by email ############################################ sub get_pw_by_email{ my $email = shift; my $return_password = ""; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Password` FROM `Account_Info` WHERE `email` = '$email';"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Password); while($sth->fetch()) { $return_password = $Password; #print "SETTING: $Password
\n"; } # disconnect from database $sth->finish(); $dbh->disconnect; #print "RP: $return_password
\n"; return $return_password; } ############################################ # Get account info by email ############################################ sub get_users_by_org_with_filter{ my $org_id = shift; my $user_filter = 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, `Account_Org_Reg_Link` c WHERE c.`Org_ID` = '$org_id' AND c.`Account_ID` = a.`Key` AND c.`Account_ID` = b.`Account_ID` $user_filter"; 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}{"EMAIL"} = $email; $return_hash{$Key}{"FIRSTNAME"} = $Firstname; $return_hash{$Key}{"LASTNAME"} = $Lastname; $return_hash{$Key}{"HOMEPHONE"} = $Home_Phone; $return_hash{$Key}{"WORK_PHONE"} = $Work_Phone; $return_hash{$Key}{"MOBILE_PHONE"} = $Mobile_Phone; $return_hash{$Key}{"ZIP_CODE"} = $Zip_Code; $return_hash{$Key}{"ADDRESS1"} = $Address1; $return_hash{$Key}{"ADDRESS2"} = $Address2; $return_hash{$Key}{"CITY"} = $City; $return_hash{$Key}{"STATE"} = $State; } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ############################################ # Get account info by email ############################################ sub get_users_by_org{ my $org_id = 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, `Account_Org_Reg_Link` c WHERE c.`Org_ID` = '$org_id' AND c.`Account_ID` = a.`Key` AND c.`Account_ID` = b.`Account_ID`"; 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}{"EMAIL"} = $email; $return_hash{$Key}{"FIRSTNAME"} = $Firstname; $return_hash{$Key}{"LASTNAME"} = $Lastname; $return_hash{$Key}{"HOMEPHONE"} = $Home_Phone; $return_hash{$Key}{"WORK_PHONE"} = $Work_Phone; $return_hash{$Key}{"MOBILE_PHONE"} = $Mobile_Phone; $return_hash{$Key}{"ZIP_CODE"} = $Zip_Code; $return_hash{$Key}{"ADDRESS1"} = $Address1; $return_hash{$Key}{"ADDRESS2"} = $Address2; $return_hash{$Key}{"CITY"} = $City; $return_hash{$Key}{"STATE"} = $State; } # disconnect from database $sth->finish(); $dbh->disconnect; return %return_hash; } ############################################ # Get account info by email ############################################ sub get_account_id_by_player_key{ my $player_key = shift; my $return_id = 0; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Account_ID` FROM `Reg_Player_Link` WHERE `Key` = '$player_key'"; my $sth = $dbh->prepare($query); #print "$query
\n"; $sth->execute(); $sth->bind_columns(\$Account_ID); while($sth->fetch()) { $return_id = $Account_ID; } # disconnect from database $sth->finish(); $dbh->disconnect; return $return_id; } ############################################ # Get account info ############################################ sub get_account_info{ my $user_key = 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.`Key` = '$user_key'"; 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 $dbh->disconnect; $sth->finish(); return %return_hash; } ############################################ # Check to see if the account exists # given the email. If it does reutrn the # key ID, otherwise return 0 ############################################ sub check_for_account{ my $new_email = shift; my $return_value = 0; my $dbh = get_dbh(); ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Key` FROM `Account_Info` WHERE `email` = '$new_email'"; my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key); while($sth->fetch()) { $return_value = $Key; } # disconnect from database $dbh->disconnect; $sth->finish(); return $return_value; } ############################################ # return email validation javascript code ############################################ sub get_email_validation{ my $html = <<__HTML__; function validate_email(emailToValidate){ if(emailToValidate.value != ""){ atposition = emailToValidate.indexOf("@"); dotposition = emailToValidate.lastIndexOf("."); if((atposition < 1)||(dotposition - atposition <2)){ return 0; } } return 1; } __HTML__ return $html; } ############################################ # return zip validation javascript code ############################################ sub get_zip_validation{ my $html = <<__HTML__; function validate_zip(zip){ var valid = 1; len=zip.length digits="0123456789" if(len != 5){ valid = 0; } for(i=0; i<5; i++){ if (digits.indexOf(zip.charAt(i))<0){ valid = 0; } } return valid; } __HTML__ return $html; } ############################################ # return phone validation javascript code ############################################ sub get_phone_validation{ my $html = <<__HTML__; __HTML__ return $html; } ################################################################ ### Check to see if the user is logged in ### This is updated to only check if cookie is there. ################################################################ ################################################################ ### Check to see if the user is logged in ################################################################ sub remote_window_check_reg_login{ #### league could be a league or an org my $league_id = shift; my $login_fail_url = shift; my $return_string = 0; my $success = 0; my $session_id = get_cookie(); my $page = "admin"; # force admin for level 3 access #my $org_id = get_org($league_id); print "SESSION ID: $session_id
\n"; my $dbh = get_dbh(); ################################################################ # Check to see if there is a valid cookie ################################################################ #print "SESSION = $session_id
\n"; if($session_id eq ""){ #print "SUCCESS: $success
\n"; $success = 0; }else{ my $login = get_login_from_session($session_id); print "\n"; $access_level = check_permissions_reg($login, $org_id, $league_id, $info_id, $page); #print "\n"; if(($page eq "admin")&&($access_level >=3)){ $success = 1; }elsif(($page eq "league")||($page eq "info")){ if($access_level >=2){ $success = 1; } } $success =1; } #print "SUCCESS: $success
\n"; if($success == 0){ #print "\n"; print <<__HTML__; __HTML__ exit(1); return 0; }else{ print "\n"; #print "\n"; return $session_id; } } sub print_my_communications_history{ my $reg_year = shift; print_show_reg_style(); print <<__HTML__; __HTML__ print "
\n"; print <<__HTML__;
My Communications History
__HTML__ print_reg_sent_email_table($reg_year); print <<__HTML__;
ViewSentSubjectFromToSent Date
__HTML__ } ################################################## # Get the contents of My Communications History # For Comm Module ################################################## sub print_reg_sent_email_table{ my $reg_year = shift; #my %user_email_history = get_user_email_history($user_id); my $dbh = get_dbh(); ####################################################### # Need to look at these queries becuase the reg could # be sent by different users. ####################################################### #my %user_data = get_user_data($user_id); #my %sender_data = get_sender_data($user_id); my $query = "SELECT a.`Key`, a.`Org_ID`, a.`League_ID`, a.`Team_ID`, a.`Create_Date`, a.`Send_Date`, a.`From_ID`, a.`Subject`, a.`Message`, a.`Context`, a.`Status`, a.`Failed` FROM `Comm_Email_Message` a, `Comm_Groups` b, `Comm_Group_Email_Link` c WHERE b.`Group_Type_ID` = '$reg_year' AND b.`Key` = c.`Comm_Group_ID` AND c.`Comm_Email_ID` = a.`Key` ORDER BY a.`Create_Date` DESC"; #print "QUERY: $query\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $html = ""; my $even_odd = 1; my $row_style = "\"cal_event3\""; while ( my $results = $sth->fetchrow_hashref ){ my $to = $sender_data{$results->{Key}}{"TO"}; my $groups_to = get_group_email_links($results->{Key}); my $from = $results->{From_ID}; my %account_info = get_account_info($from); my $from_name = $account_info{"FIRSTNAME"} . " " . $account_info{"LASTNAME"}; if($to eq ""){ $to .= $groups_to; }else{ $to .= "," . $groups_to; } $to =~ s/\,/\, /g; if($to =~ m/ALL$/){ $to = "All Registrants"; }elsif($to =~ m/BalDue$/){ $to = "Registrants with Balance Due"; } my $view_email_link = ""; if($even_odd == 1){ $row_style = "\"cal_events2\""; $even_odd = 2; }else{ $row_style = "\"cal_events3\""; $even_odd = 1; } my $current_status = "Not Sent"; if($results->{Status} == 1){ $current_status = "In Progress"; }elsif($results->{Status} == 2){ $current_status = "Sent"; }elsif($results->{Status} == -1){ $current_status = "Had Error(s)"; } $html .= "
" . $view_email_link . "view$current_status" . $results->{Subject} . "" . $from_name . "" . $to . "" . $results->{Send_Date} . "