require "hometeamz_lib.pm"; ################################################################ ### Convert Date from mm/dd/yyyy to yyyy-mm-dd for DB ################################################################ sub convert_date_no_time_to_db{ my $date = shift; my ($month,$day,$year) = split(/\//,$date); my $return_date = "$year-$month-$day"; return $return_date; } ################################################################ ### Convert Date from yyyy-mm-dd to mm/dd/yyyy for Display ################################################################ sub convert_date_no_time_to_display{ my $date = shift; my ($year,$month,$day) = split(/-/,$date); my $return_date = "$month/$day/$year"; return $return_date; } ################################################################ ### Get the current (month or year) ### Inputs: Month or year ### Return: Current (Month Or Year) ################################################################ sub get_current { my $return_type = shift; my $current_time = timelocal((localtime)[0..5]); my $return_string = 0; my($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); if($return_type eq "year"){ #Add 1900 to Years, because it begins at 1900, ex 2004=104; $year = $year + 1900; $return_string = $year; }elsif($return_type eq "month"){ #Jan = 0 $month = $month +1; $return_string = $month; } return $return_string; } ################################################################ ### Get the last day of the month ### Inputs: Month and year of the last day ### Return: Last day of the month ################################################################ sub get_last_day { my $current_month = shift; my $current_year = shift; my $return_string = 0; my $last_day = 28; my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); $month = $current_month; $current_time = timelocal(0,0,0,$last_day,$current_month-1,$current_year-1900); while($month == $current_month){ $current_time = $current_time + (60 * 60 * 24); ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); #Jan = 0 so add one $month++; if($month != $current_month){ $return_day = $last_day; }else{ $last_day = $day; } } return $return_day,$return_dow; } ################################################################ ### Get the day of week (mon, tue, etc) ### Inputs: Month day year ### Return: Day of the week ################################################################ sub get_day_of_week { my $current_month = shift; my $current_day = shift; my $current_year = shift; my $return_string = 0; my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); $current_time = timelocal(0,0,0,$current_day,$current_month-1,$current_year-1900); ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); $return_string = $wday; return $return_string; } ################################################################ ### print_extra_day is used to print the days before and ### after the month to fill the calendar ################################################################ sub print_extra_day { my $current_month = shift; my $current_year = shift; my $extra_type = shift; my $days_offset = shift; my $start_day = shift; my $league = shift; my $coach = shift; my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); my $current_time = timelocal(0,0,0,$start_day,$current_month-1,$current_year-1900); ### Determine if the day is before or after the month ### and Calculate the offset in epoch seconds if($extra_type eq "previous"){ $current_time = $current_time - (60*60*24*$days_offset); }elsif($extra_type eq "following"){ $current_time = $current_time + (60*60*24*$days_offset); } ### Change to Real Date ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); $month++; $year = $year + 1900; ### Print the day print_calendar_day($month, $day, $year, "gray", $league, $coach); #print "$month/$day/$year\n"; } ################################################################ ### print_extra_day is used to print the days before and ### after the month to fill the calendar ################################################################ sub print_extra_day_small { my $current_month = shift; my $current_year = shift; my $extra_type = shift; my $days_offset = shift; my $start_day = shift; my $league = shift; my $coach = shift; my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); my $current_time = timelocal(0,0,0,$start_day,$current_month-1,$current_year-1900); ### Determine if the day is before or after the month ### and Calculate the offset in epoch seconds if($extra_type eq "previous"){ $current_time = $current_time - (60*60*24*$days_offset); }elsif($extra_type eq "following"){ $current_time = $current_time + (60*60*24*$days_offset); } ### Change to Real Date ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); $month++; $year = $year + 1900; ### Print the day print_calendar_day_small($month, $day, $year, "gray", $league, $coach); #print "$month/$day/$year\n"; } ################################################################# ### print_calendar_day is used to print any day given the ### day, month and year ################################################################ sub print_calendar_day { my $current_month = shift; my $current_day = shift; my $current_year = shift; my $bgcolor = shift; my $league = shift; my $coach = shift; my @current_events = (); my $current_time = timelocal(0,0,0,$current_day,$current_month-1,$current_year-1900); my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); my $day_file = "$org/$league/CAL/$current_year/$current_month/$current_day.txt"; my ($obj_id,$time,$event_type,$home_team,$home_score,$away_team,$away_score,$description); #print "$day_file
\n"; if(-e $day_file){ open(IN, $day_file)|| die "ERROR: $! Could not open $day_file\n"; while(){ chomp; push(@current_events, $_) } close(IN); } ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); if($wday == 0){ print " \n"; } print " \n"; if($coach){ print " $current_day\n"; }else{ print " $current_day\n"; } print " \n"; foreach(@current_events){ ($obj_id,$time,$event_type,$home_team,$home_score,$away_team,$away_score,$description)= split(/\$\|\$/,$_); if($event_type eq "GAME"){ if(($home_score ne "NA" and $away_score ne "NA")){ if($home_score > $away_score){ print " \n"; }else{ print " \n"; } }else{ print " \n"; } }elsif($event_type eq "EVENT"){ print " \n"; } } #$current_events_lenght = @ if(@current_events + 0 == 0){ print " \n"; print " \n"; print " \n"; } print "
$time $away_team($away_score) @ $home_team($home_score)
$time $away_team($away_score) @ $home_team($home_score)
$time $away_team @ $home_team
$time $description
 
 
 
\n"; print " \n"; if($wday == 6){ print " \n"; } } ################################################################ ### print_calendar_day is used to print any day given the ### day, month and year ################################################################ sub print_calendar_day_small { my $current_month = shift; my $current_day = shift; my $current_year = shift; my $bgcolor = shift; my $league = shift; my $coach = shift; my $current_time = timelocal(0,0,0,$current_day,$current_month-1,$current_year-1900); my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); my ($obj_id,$time,$event_type,$home_team,$home_score,$away_team,$away_score,$description); ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); if($wday == 0){ print " \n"; } print " \n"; if($coach){ print " $current_day\n"; }else{ print " $current_day\n"; } print " \n"; if($wday == 6){ print " \n"; } } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header_all_events2 { my $current_month = shift; my $current_year = shift; my $league = shift; my $coach = shift; my $filter = shift; my $season = "2005"; my $colspan = 3; my $end_time = ""; if($show_end_time == 1){ $colspan++; $end_time = "End Time"; } print <<__HTML__; __HTML__ ################################################################ # Get the next & previous month and year combinations ################################################################ my ($next_month, $next_year) = get_next_month($current_month, $current_year, "next"); my ($prev_month, $prev_year) = get_next_month($current_month, $current_year, "prev"); my ($minus_two_month, $minus_two_year) = get_next_month($prev_month, $prev_year, "prev"); my ($minus_three_month, $minus_three_year) = get_next_month($minus_two_month, $minus_two_year, "prev"); my ($plus_two_month, $plus_two_year) = get_next_month($next_month, $next_year, "next"); my ($plus_three_month, $plus_three_year) = get_next_month($plus_two_month, $plus_two_year, "next"); ################################################################ # Get Month abreviations ################################################################ my $current_month_name = get_month_name_small($current_month); my $prev_month_name = get_month_name_small($prev_month); my $next_month_name = get_month_name_small($next_month); my $minus_two_month_name = get_month_name_small($minus_two_month); my $minus_three_month_name = get_month_name_small($minus_three_month); my $plus_two_month_name = get_month_name_small($plus_two_month); my $plus_three_month_name = get_month_name_small($plus_three_month); my $bgcolor = "#be0203"; my %teamsa = get_league_teams($league_id); foreach $key (keys %teamsa){ $teams{$teamsa{$key}} = $key; } #print "\n"; print "
    $season Season    
Print Month Print Season
"; #print "\n"; #print "
League Events\n"; print ""; $html .= ""; $html .= ""; } $sth->finish(); $dbh->disconnect; print $html; } sub get_group_email_links{ my $email_id = shift; my $dbh = get_dbh(); my $query = "SELECT b.`Group_Name` FROM `Comm_Group_Email_Link` a, `Comm_Groups` b WHERE a.`Comm_Email_ID` = '$email_id' AND a.`Comm_Group_ID` = b.`Key`"; my $group_email_links = ""; my $comma = ""; my $sth = $dbh->prepare($query); $sth->execute(); while ( my $results = $sth->fetchrow_hashref ){ $group_email_links .= $comma . $results->{Group_Name}; $comma = ","; } $sth->finish(); $dbh->disconnect; return $group_email_links; } ################################################################ ### If the admin is logged in, print the admin mode page ################################################################ sub print_admin{ my $org_id = shift; my $amdin = shift; my $user = shift; my $pass = shift; my $sub = shift; my $color = "#006699"; my $session_id = 1; my $reg_count = get_num_of_registrations($org_id); my $manage_reg_link = ""; my $num_controls = 6; my $show_reg = 1; if($show_reg == 1){ $num_controls = 7; $manage_reg_link = "\n"; } if($count == 1){ print "
\n"; print "\n"; print "\n"; print "\n"; if($coach){ print "$end_time\n"; }else{ print "$end_time\n"; } } sub get_all_teams{ my $dbh = get_dbh(); # prepare and execute query my $query = "SELECT * FROM Team_Info ORDER BY Team_Name ASC"; #print "$query
\n"; my $sth = $dbh->prepare($query); my %return_hash; my $ID; my $event_type; $sth->execute(); # assign fields to variables $sth->bind_columns(\$ID, \$League_ID, \$Team_Name, \$Division_ID, \$Status); # output name list to the browser while($sth->fetch()) { $return_hash{$ID} = $Team_Name; } $sth->finish(); # disconnect from database $dbh->disconnect; return %return_hash; } sub get_all_leagues{ my $dbh = get_dbh(); # prepare and execute query my $query = "SELECT `Key`, `League_Name` FROM League_Info"; #print "$query
\n"; my $sth = $dbh->prepare($query); my %return_hash; my $ID; $sth->execute(); # assign fields to variables $sth->bind_columns(\$ID, \$League_Name); # output name list to the browser while($sth->fetch()) { $return_hash{$ID} = $League_Name; } $sth->finish(); # disconnect from database $dbh->disconnect; return %return_hash; } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header_linked_league { my $current_month = shift; my $current_year = shift; my $league = shift; my $coach = shift; my $filter = shift; my $org_id = shift; my $league_id = shift; my $season = "2005"; print <<__HTML__; __HTML__ ################################################################ # Get Month abreviations ################################################################ my $current_month_name = get_month_name_small($current_month); my $colspan = 3; my $bgcolor = "#be0203"; my %teamsa = get_league_teams($league_id); if($coach == 0){ $colspan = 1; } foreach $key (keys %teamsa){ $teams{$teamsa{$key}} = $key; } print "
League Events\n"; print "  \n"; print "
Date/TimeEvent TypeTeamsLocationNotesUpdate
Date/TimeEvent TypeTeamsLocationNotes
Print Month Print Season
"; print ""; $html .= ""; $html .= ""; $num_groups++; } $sth->finish(); $dbh->disconnect; if($num_groups == 0){ $html .= ""; } print $html; } ################################################## # Get the contents of My Communications History # For Comm Module ################################################## sub print_custom_groups{ my $user_id = shift; my $tag = shift; #my %user_email_history = get_user_email_history($user_id); my $dbh = get_dbh(); my $query = "SELECT `Key`,`Org_ID`,`Group_Name`,`Group_Type`,`Group_Type_ID`, `Desc` FROM `Comm_Groups` WHERE `Owner_ID` = '$user_id' AND `Active` = '1' ORDER BY `Group_Name`"; #print "QUERY: $query\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $html = ""; my $even_odd = 1; my $row_style = "\"cal_event3\""; my $num_groups = 0; while ( my $results = $sth->fetchrow_hashref ){ my $current_key = $results->{Key}; my $group_count = get_group_count($current_key); my $group_name = $results->{Group_Name}; my $view_email_link = ""; if($even_odd == 1){ $row_style = "\"cal_events2\""; $even_odd = 2; }else{ $row_style = "\"cal_events3\""; $even_odd = 1; } $html .= ""; $html .= ""; $html .= ""; $num_groups++; } $sth->finish(); $dbh->disconnect; if($num_groups == 0){ $html .= ""; } print $html; } sub get_group_count{ my $group_id = shift; my $dbh = get_dbh(); my $query = "SELECT COUNT(*) as GROUPCOUNT FROM `Comm_Group_Address_Link` WHERE `Comm_Group_ID` = '$group_id' AND `Blacklisted_From_Group` = '0'"; my $sth = $dbh->prepare($query); my $group_count = 0; $sth->execute(); $group_count = $sth->fetchrow_arrayref->[0]; $sth->finish(); $dbh->disconnect; return $group_count; } ########################################### # Print the email history for user ########################################### sub print_my_communications_history{ my $user = shift; print <<__HTML__;
\n"; print "\n"; print "\n"; print " \n"; } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header_all_events { my $current_month = shift; my $current_year = shift; my $league = shift; my $coach = shift; my $filter = shift; my $season = "2005"; my $test_filter = 0; if($filter == -2){ $test_filter = -2; $filter = 0; } print <<__HTML__; __HTML__ ################################################################ # Get the next & previous month and year combinations ################################################################ my ($next_month, $next_year) = get_next_month($current_month, $current_year, "next"); my ($prev_month, $prev_year) = get_next_month($current_month, $current_year, "prev"); my ($minus_two_month, $minus_two_year) = get_next_month($prev_month, $prev_year, "prev"); my ($minus_three_month, $minus_three_year) = get_next_month($minus_two_month, $minus_two_year, "prev"); my ($plus_two_month, $plus_two_year) = get_next_month($next_month, $next_year, "next"); my ($plus_three_month, $plus_three_year) = get_next_month($plus_two_month, $plus_two_year, "next"); ################################################################ # Get Month abreviations ################################################################ my $current_month_name = get_month_name_small($current_month); my $prev_month_name = get_month_name_small($prev_month); my $next_month_name = get_month_name_small($next_month); my $minus_two_month_name = get_month_name_small($minus_two_month); my $minus_three_month_name = get_month_name_small($minus_three_month); my $plus_two_month_name = get_month_name_small($plus_two_month); my $plus_three_month_name = get_month_name_small($plus_three_month); my $colspan = 3; my $bgcolor = "#be0203"; my %teamsa = get_league_teams($league_id); if($coach == 0){ $colspan = 1; } foreach $key (keys %teamsa){ $teams{$teamsa{$key}} = $key; } if($show_end_time == 1){ $colspan++; } print "
$current_month_name
Print Month Print Season
"; #print "\n"; print "
    $season Season    
\n"; print "\n"; print "\n"; print "\n"; } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header { my $current_month = shift; my $current_year = shift; my $league = shift; my $bgcolor = "#006699"; my $current_month_name = get_month_name($current_month); my ($next_month, $next_year) = get_next_month($current_month, $current_year, "next"); my ($prev_month, $prev_year) = get_next_month($current_month, $current_year, "prev"); print "
League Events\n"; print "  \n"; print "
\n"; print "\n"; } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header_small { my $current_month = shift; my $current_year = shift; my $league = shift; my $bgcolor = "#006699"; my $current_month_name = get_month_name_small($current_month); my ($next_month, $next_year) = get_next_month($current_month, $current_year, "next"); my ($prev_month, $prev_year) = get_next_month($current_month, $current_year, "prev"); print "
<<     $current_month_name $current_year     >>
SunMonTueWedThuFriSat
\n"; print "\n"; } ################################################################ ### Return the next month based on the month that was passed in ################################################################ sub get_next_month{ my $current_month = shift; my $current_year = shift; my $next_or_prev = shift; my $current_day = 27; my $next_month = $current_month; my $next_year = 0; my $current_time = timelocal(0,0,0,$current_day,$current_month-1,$current_year-1900); my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); while($next_month == $current_month){ if($next_or_prev eq "next"){ $current_time = $current_time + (60*60*24); }else{ $current_time = $current_time - (60*60*24); } ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); $month = $month +1; if($month != $current_month){ $next_month = $month; $next_year = $year + 1900; } } return $next_month, $next_year; } ################################################################ ### Return the next month based on the month that was passed in ################################################################ sub get_next_day{ my $current_month = shift; my $current_year = shift; my $current_day = shift; my $next_or_prev = shift; my $next_day = 0; my $next_year = 0; my $next_month = 0; my $current_time = timelocal(0,0,0,$current_day,$current_month-1,$current_year-1900); my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); if($next_or_prev eq "next"){ $current_time = $current_time + (60*60*24); }else{ $current_time = $current_time - (60*60*24); } ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); $next_month = $month +1; $next_year = $year + 1900; $next_day = $day; return $next_month, $next_year, $next_day; } ################################################################ ### Return the name of the month based from the number ################################################################ sub get_month_name{ my $month_number = shift; @months = ('','January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); return $months[$month_number]; } ################################################################ ### Return the name of the month(short) based from the number ################################################################ sub get_month_name_small{ my $month_number = shift; @months = ('','Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); return $months[$month_number]; } ################################################################ ### Return the name of the day(short) based from the number ################################################################ sub get_day_name{ my $day_number = shift; @days = ('Sun','Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'); return $days[$day_number]; } ################################################################ ### print_calendar_footer closes the calendar ################################################################ sub print_calendar_footer { print "
<<     $current_month_name $current_year     >>
SMTWTFS
\n"; } ################################################################ ### print_calendar prints a calendar as a table give month and ### year ################################################################ sub print_calendar_small { my $current_month = shift; my $current_year = shift; my $league = shift; my $coach = shift; my $first_day_of_month = 0; my $last_day_of_month = 0; print_calendar_header_small($current_month,$current_year,$league); ($current_last,$current_last_dow) = get_last_day($current_month, $current_year); ### get the first day (mon, tue, etc) of the month to see if an extra days ### are needed from the previous month $first_day_of_month = get_day_of_week($current_month, 1, $current_year); if($first_day_of_month != 0){ for($i=$first_day_of_month;$i>0;$i--){ print_extra_day_small($current_month,$current_year,"previous",$i,1,$league, $coach); } } ### Loop through the days of the month to print them for($i=1;$i<=$current_last;$i++){ #print "$current_month/$i/$current_year\n"; print_calendar_day_small($current_month, $i, $current_year, "white", $league, $coach); } ### get the last day (mon, tue, etc) of the month to see if an extra days ### are needed from the next month $last_day_of_month = get_day_of_week($current_month, $current_last, $current_year); if($last_day_of_month != 6){ for($i=1;$i<=6-$last_day_of_month;$i++){ print_extra_day_small($current_month,$current_year,"following",$i,$current_last,$league,$coach); } } print_calendar_footer(); } ################################################################ ### Opens a data file and adds info to it ################################################################ sub add_to_file{ my $file = shift; my $data = shift; my $placement = shift; my @data = (); my $tmp_file = "$file.$$"; my $obj_id_file = "$file.obj_id"; my $current_line = ""; my $obj_id = 0; $obj_id = add_obj_id($obj_id_file); $data = "$obj_id" . '$|$' . "$data"; chomp($data); $data .= "\n"; ### Check to see if we want line to begining of file ### if($placement eq "begining"){ push(@data, $data); } ### Check to see if file exists ### if(!(-e $file)){ ### If not create one ### open(NEW, ">$file") || die "ERROR: Could not write to $file\n"; close(NEW); } open(IN, "$file") || die "ERROR: Could not write to $file\n"; while(){ chomp; $current_line = "$_\n"; push(@data, $current_line); } ### Check to see if we want line to end of file ### if($placement eq "end"){ push(@data, $data); } close(IN); open(OUT, ">$tmp_file") || die "ERROR: Could not open to $tmp_file\n"; print OUT @data; close(OUT); rename $tmp_file, $file; } ################################################################ ### Delete a line from a file ################################################################ sub delete_from_file{ my $file = shift; my $obj_id = shift; my @data = (); my $tmp_file = "$file.$$"; my $current_line = ""; my $current_obj_id = 0; open(IN, "$file") || die "ERROR: Could not open to $file\n"; while(){ chomp; $current_line = "$_\n"; ($current_obj_id, $current_date) = split(/\$\|\$/,$current_line); if($current_obj_id == $obj_id){ }else{ push(@data, $current_line); } } close(IN); open(OUT, ">$tmp_file") || die "ERROR: Could not open to $tmp_file\n"; print OUT @data; close(OUT); rename $tmp_file, $file; } ################################################################ ### Update an item in a file ################################################################ sub update_file{ my $file = shift; my $obj_id = shift; my $data = shift; my @data = (); my $tmp_file = "$file.$$"; my $current_line = ""; my $update_data = $obj_id . '$|$' . $data . "\n"; open(IN, "$file") || die "ERROR: Could not open to $file\n"; while(){ chomp; $current_line = "$_\n"; ($current_obj_id, $current_date) = split(/\$\|\$/,$current_line); if($current_obj_id == $obj_id){ push(@data, $update_data); print "UPDATING: $update_data\n"; }else{ push(@data, $current_line); } } close(IN); open(OUT, ">$tmp_file") || die "ERROR: Could not open to $tmp_file\n"; print OUT @data; close(OUT); rename $tmp_file, $file; } ################################################################ ### Get the latest objID of a file ################################################################ sub get_obj_id{ my $obj_id_file = shift; my $return_obj_id = 0; if(!(-e $obj_id_file)){ $return_obj_id = -1; }else{ open(OBJ, "$obj_id_file") || die "ERROR: Could not write to $obj_id_file\n"; while(){$return_obj_id = $_;} close(OBJ); } return $return_obj_id; } ################################################################ ### Increment objID for a file ################################################################ sub add_obj_id{ my $obj_id_file = shift; my $obj_id = get_obj_id($obj_id_file); $obj_id++; open(OBJ, ">$obj_id_file") || die "ERROR: Could not write to $obj_id_file\n"; print OBJ $obj_id; close(OBJ); return $obj_id; } ################################################################ ### Print the update news block (HTML portion) ################################################################ sub print_news_update_block{ my $title = shift; my $date = shift; my $news = shift; my $color = shift; my $league_id = shift; $date = get_date(); print <<__HTML__;
$date add
__HTML__ } ################################################################ ### Print the normal news block (HTML portion) ################################################################ sub print_info_block{ my $message_id = shift; my $title = shift; my $date = shift; my $text = shift; my $color = $site_info{"message_box_bg_color"}; my $text_color = $site_info{"message_box_text_color"}; my $admin = shift; my $org_id = shift; my $page_id = shift; my $first = shift; my $last = shift; my $page_type = shift; my $e_info_key = shift; my $type = ""; my $extra_info = ""; ################################################ ## Convert Date ################################################ ($current_date, $current_time) = split(/\s+/, $date); $current_date = convert_date_to_display($current_date); if($page_type eq "league"){ $type = "league_id"; $extra_info = "&info_id=$e_info_key"; }else{ $type = "info_id"; } print <<__HTML__;
$title Updated $current_date __HTML__ if($admin ==1){ print "edit del\n"; if($first){ print "Move Up\n"; }else{ print "Move Up\n"; } if($last){ print "Move Down\n"; }else{ print "Move Down\n"; } } ##############################3 # This series of search and replace # Are to compensate for when the site was move # When there is time to update all links, this # should be fixed. ############################################## $text =~ s/http:\/\/www.hometeamz.com\/teamdata\//\/teamdata\//g; $text =~ s/\/teamdata\//$hometeamz_dir\/teamdata\//g; $text =~ s/hometeamzhometeamz/hometeamz/g; print <<__HTML__;
$text


__HTML__ } ################################################################ ### Print the normal news block (HTML portion) ################################################################ sub print_news_block{ my $obj_id = shift; my $title = shift; my $date = shift; my $news = shift; my $color = shift; my $update = shift; my $league_id = shift; print <<__HTML__;
$title Updated $date __HTML__ if($update ==1){ print "edit del\n"; } print <<__HTML__;
$news

__HTML__ } ################################################################ ### Get current date information ################################################################ sub get_date{ my $return_string = ""; #get current_time in seconds $current_time = timelocal((localtime)[0..5]); my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); #Add 1900 to Years, because it begins at 1900, ex 2004=104; $year = $year + 1900; #Jan = 0 $month = $month +1; $return_string = "$month/$day/$year"; return $return_string; } ################################################################ ### Get Date for next year ################################################################ sub get_next_year_date{ my $return_string = ""; #get current_time in seconds $current_time = timelocal((localtime)[0..5]); $current_time = $current_time + 31556926; my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); #Add 1900 to Years, because it begins at 1900, ex 2004=104; $year = $year + 1900; #Jan = 0 $month = $month +1; $return_string = "$month/$day/$year"; return $return_string; } ################################################################ ### Get current date time information ################################################################ sub get_date_time{ my $return_string = ""; #get current_time in seconds $current_time = timelocal((localtime)[0..5]); my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime($current_time); #Add 1900 to Years, because it begins at 1900, ex 2004=104; $year = $year + 1900; #Jan = 0 $month = $month +1; $hour = sprintf("%02d", $hour); $min = sprintf("%02d", $min); $sec = sprintf("%02d", $sec); $month = sprintf("%02d", $month); $day = sprintf("%02d", $day); $return_string = "$year-$month-$day $hour:$min:$sec"; return $return_string; } ################################################################ ### Print the top menu bar ################################################################ sub print_comm_header{ print <<__HTML__;
__HTML__ print "My Communications\n"; print " \n"; print "$site_info{\"org_full\"}\n"; print "\n"; print "Logout\n"; print "
\n"; print "
\n"; print "
\n"; } ################################################################ ### Print the top menu bar ################################################################ sub print_admin_header{ my $org = shift; print <<__HTML__;
__HTML__ print "$org Admin\n"; print " \n"; print "$site_info{\"org_full\"}\n"; print "\n"; print "Logout\n"; print "
\n"; print "
\n"; print "
\n"; } ################################################################ ### Print the top menu bar ################################################################ sub print_league_only_header{ my $league = shift; my $sub = shift; my $coach = shift; my $league_id = shift; # print <<__HTML__; #
# #
#__HTML__ # $display_league = $league; # $display_league = substr($display_league,0,20); # $display_league =~ s/\s+/ /g; # if($coach){ # print "$display_league Admin\n"; # }else{ # print "$display_league\n"; # } # print " \n"; # if($coach){ # print "News |\n"; # print "Schedules |\n"; # print "Standings |\n"; # print "Tournament |"; # print "Options\n"; # }else{ # print "News   |  \n"; # print "Schedules   |  \n"; # print "Standings   |  \n"; # print "Tournament \n"; # } # print "\n"; # if($coach){ # print "Logout\n"; # }else{ # print "Admin\n"; #print "Admin\n"; # } # print "
\n"; # print "
\n"; # print "
\n"; } ################################################################ ### Print the top menu bar ################################################################ sub print_league_header{ my $league = shift; my $sub = shift; my $coach = shift; my $league_id = shift; $display_league = $league; $display_league = substr($display_league,0,24); $display_league =~ s/\s+/ /g; if($coach){ $top_menu = "top_menu"; $more_top_menu = "more_top_menu"; $display_header_string = "$display_league Admin"; }else{ $top_menu = "top_menu"; $display_header_string = "$display_league"; $more_top_menu = "more_top_menu"; } print <<__HTML__;
$display_header_string __HTML__ if($coach){ print "News |\n"; print "Schedules |\n"; print "Standings |\n"; print "Tournament |\n"; print "Options\n"; }else{ print "News   |  \n"; print "Schedules   |  \n"; print "Standings   |  \n"; print "Tournament \n"; } print "\n"; if($coach){ print "Logout\n"; }else{ print "Admin\n"; #print "Admin\n"; } print "
\n"; print "
\n"; print "
\n"; } ################################################################ ### This will print the page for different league headers ################################################################ sub print_info{ my $info_id = shift; my $admin = shift; my $color = "#006699"; my $first = 1; my $count = 0; my $last = 0; my $page_name = get_page_name($info_id); ################################################################ ## Print Context Area header (ie PYB or The League Name) ################################################################ print <<__HTML__;
  $page_name __HTML__ if($admin == 1){ print "Logout\n"; }else{ print "Admin\n"; } print <<__HTML__;

__HTML__ if($admin == 1){ #print_update_news($league, $org_id, $league_id, $color); #check_login("","",$org_id); print "
\n"; print "\n"; } print "

\n"; print_marquee($info_id); ################################################################ ## Get all message blurps for this page. ################################################################ my $dbh = get_dbh(); my $query = "SELECT count( * ) FROM `Infopage_Info` WHERE `Page_ID` = $info_id"; my $sth = $dbh->prepare($query); $sth->execute(); my $total = $sth->fetchrow_arrayref->[0]; # prepare and execute query $query = "SELECT * FROM `Infopage_Info` WHERE `Page_ID` = $info_id Order By `Order`"; $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Key, \$Org_ID, \$Page_ID, \$Date, \$Title, \$Order, \$Text); while($sth->fetch()) { $count++; if($count == $total){$last =1;} #print "COUNT: $count - TOTAL: $total
\n"; print_info_block($Key,$Title,$Date,$Text,$admin,$org_id,$info_id,$first,$last,"info",0); $first = 0; } $sth->finish(); # disconnect from database $dbh->disconnect; print <<__HTML__;
__HTML__ } sub print_marquee{ my $page_id = shift; my $marquee = 0; my $dbh = get_dbh(); my $query = "SELECT * FROM `Marquee_Info` WHERE `Page_ID` = $page_id"; my $sth = $dbh->prepare($query); $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Key, \$Org_ID, \$Page_ID, \$Behavior, \$ScrollDelay, \$ScrollAmount, \$Direction, \$Text); while($sth->fetch()) { print "
$Text

\n"; } $sth->finish(); # disconnect from database $dbh->disconnect; } ################################################################ ### This logs the user out. ################################################################ sub print_logout{ my $org_id = shift; print <<__HTML__;
$site_info{"org_full"}


You have signed out of $site_info{"org_short"} Admin.
Return to $site_info{"org_short"} Home.
__HTML__ } ################################################################ ### This handles what comes up first for a team ################################################################ sub print_home{ my $org_id = shift; my $dbh = get_dbh(); # prepare and execute query my $query = "SELECT * FROM `Org_Info` WHERE `Key` = $org_id"; my $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Key, \$Org_Name, \$Org_Display_Name); $sth->finish(); # disconnect from database $dbh->disconnect; print <<__HTML__;
$Org_Display_Name $org_id

Current Events
  • 4/8 Draft
  • 5/8 Opening Day
__HTML__ } ################################################################ ### If the coach is logged in, print the coach mode page ################################################################ sub print_coach{ my $league = shift; my $sub = shift; my $color = "#006699"; my $org_id = shift; my $league_id = shift; my $user = shift; my $pass = shift; my $filter = shift; my $session_id = ""; my $menu_type = get_league_menu_type($league_id, $org_id); ################################################################ ### Get the league Name and print the header bar ### i.e. Standing | Calendar | News ################################################################ $league = get_league_name($league_id); print_league_header($league,$sub,1,$league_id); #$session_id = check_login($user, $pass, $league_id); #$session_id = get_cookie(); #if($session_id eq ""){ #print_login_block($org_id,"league",$league_id,1); #print "Your session has timed out, please login again.
\n"; #}else{ ################################################################ ### Determine whether to print the news, standing or calendar ################################################################ if($sub eq 'news'){ print_news($league, $org_id, $league_id, $color, 1); }elsif($sub eq 'standings'){ print "

\n"; if($menu_type ne "team"){ print_standings($league, $org_id, $league_id, 1); }else{ @linked_leagues = get_linked_leagues($league_id); my $first = 1; foreach(@linked_leagues){ $league = get_league_name($_); $linked_org = get_org_full_from_league($_); $linked_url = get_org_url_from_league($_); print_linked_event_header("Standings", $league, $linked_url, $linked_org, $first); print_standings("NOT SURE", 0, $_, 0); $first = 0; } if($first == 1){ print "

No Standings available for this Team
\n"; } } }elsif($sub eq 'calendar'){ print_league_calendar($league, $month, $year, 1, $org_id, $league_id, $filter, $menu_type); }elsif($sub eq 'tournament'){ print "
\n"; print_tournament_coach($league_id); @linked_leagues = get_linked_leagues($league_id); foreach(@linked_leagues){ $league = get_league_name($_); $linked_org = get_org_full_from_league($_); $linked_url = get_org_url_from_league($_); print_linked_event_header("Tournaments", $league, $linked_url, $linked_org, 0); print_tournament($_, $league, $league_url); } print "\n"; }elsif($sub eq 'options'){ print_options_coach($league_id); } ################################################################ ### Not sure where this div starts???? ################################################################ #} print "\n"; } sub print_login_block{ my $org_id = shift; my $page_type = shift; my $page_id = shift; my $admin = shift; my $coach = shift; print "

\n"; print <<__HTML__;
Sign In    
__HTML__ if($page_type eq "field"){ print "\n"; print " \n"; }elsif($page_type ne ""){ print "\n"; print " \n"; }else{ print " \n"; } print <<__HTML__;
ID:
Password:
__HTML__ } ################################################################ ### Print the top menu bar ################################################################ sub print_login_header{ print <<__HTML__;
 
__HTML__ } ################################################################ ### If the admin is logged in, print the admin mode page ################################################################ ################################################################ # Get all reg setup info from org id ################################################################ sub get_reg_setup_hash_by_org_and_reg_year{ my $org_id = shift; my $reg_year = shift; my $dbh = get_dbh(); my %return_hash; ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Secure_URL`, `Org_Dir`, `Reg_File`, `Reg_Admin_File`, `Reg_Year`, `Org_Caps`, `Home_Page_URL`, `Default_State`, `Min_Partial_Pay`, `Reply_To`, `From`, `Org_Full_Name_For_Email`, `Season_Text`, `Welcome_Text`, `Information_Text`, `Pay_Complete_Message`, `Pay_By_Check_Message`, `Paypal_Account`, `Return_URL`, `IPN_URL`, `Paypal_URL`,`Require_Confirmation`, `Require_Confirmation_MSG`, `League_Assign`, `Num_Register_Names`, `Register_Type`, `Test_Paypal`, `Ok_To_Pay_By_Check` FROM `Reg_Setup` WHERE `Org_ID` = '$org_id' AND `Reg_Year` = '$reg_year'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); while (my $hash_ref = $sth->fetchrow_hashref) { my $reg_year = $hash_ref->{Reg_Year}; my $org_caps = $hash_ref->{Org_Caps}; $return_hash{$reg_year}{"ORG_CAPS"} = $org_caps; my $min_partial_pay = $hash_ref->{Min_Partial_Pay}; $return_hash{$reg_year}{"MIN_PARTIAL_PAY"} = $min_partial_pay; my $reply_to = $hash_ref->{Reply_To}; $return_hash{$reg_year}{"REPLY_TO"} = $reply_to; my $from = $hash_ref->{From}; $return_hash{$reg_year}{"FROM"} = $from; my $org_full_name_for_email = $hash_ref->{Org_Full_Name_For_Email}; $return_hash{$reg_year}{"FULL_NAME"} = $org_full_name_for_email; my $season_text = $hash_ref->{Season_Text}; $return_hash{$reg_year}{"SEASON_TEXT"} = $season_text; my $welcome_text = $hash_ref->{Welcome_Text}; $return_hash{$reg_year}{"WELCOME_TEXT"} = $welcome_text; my $information_text = $hash_ref->{Information_Text}; $return_hash{$reg_year}{"INFORMATION_TEXT"} = $information_text; my $pay_complete_message = $hash_ref->{Pay_Complete_Message}; $return_hash{$reg_year}{"PAY_COMPLETE_MSG"} = $pay_complete_message; my $pay_by_check_message = $hash_ref->{Pay_By_Check_Message}; $return_hash{$reg_year}{"PAY_BY_CHECK_MSG"} = $pay_by_check_message; my $paypal_acc = $hash_ref->{Paypal_Account}; $return_hash{$reg_year}{"PAYPAL_ACC"} = $paypal_acc; my $return_url = $hash_ref->{Return_URL}; $return_hash{$reg_year}{"RETURN_URL"} = $return_url; my $secure_url = $hash_ref->{Secure_URL}; $return_hash{$reg_year}{"SECURE_URL"} = $secure_url; my $reg_file = $hash_ref->{Reg_File}; $return_hash{$reg_year}{"REG_FILE"} = $reg_file; my $reg_admin_file = $hash_ref->{Reg_Admin_File}; $return_hash{$reg_year}{"REG_ADMIN_FILE"} = $reg_admin_file; my $org_dir = $hash_ref->{Org_Dir}; $return_hash{$reg_year}{"ORG_DIR"} = $org_dir; my $thanks_url = "$secure_url/$org_dir/$reg_file?action=pp"; $return_hash{$reg_year}{"THANKS_URL"} = $thanks_url; my $ipn_url = $hash_ref->{IPN_URL}; $return_hash{$reg_year}{"IPN_URL"} = $ipn_url; my $base_reg_url = "$secure_url/$org_dir/$reg_file"; $return_hash{$reg_year}{"BASE_REG_URL"} = $base_reg_url; my $admin_reg_url = "$secure_url/$org_dir/$reg_admin_file"; $return_hash{$reg_year}{"ADMIN_REG_URL"} = $admin_reg_url; my $paypal_url = $hash_ref->{Paypal_URL}; $return_hash{$reg_year}{"PAYPAL_URL"} = $paypal_url; my $default_state = $hash_ref->{Default_State}; $return_hash{$reg_year}{"DEFAULT_STATE"} = $default_state; my $home_page_url = $hash_ref->{Home_Page_URL}; $return_hash{$reg_year}{"HOME_PAGE_URL"} = $home_page_url; my $require_confirmation = $hash_ref->{Require_Confirmation}; $return_hash{$reg_year}{"REQUIRE_CONFIRMATION"} = $require_confirmation; my $require_confirmation_msg = $hash_ref->{Require_Confirmation_MSG}; $return_hash{$reg_year}{"REQUIRE_CONFIRMATION_MSG"} = $require_confirmation_msg; my $league_assign = $hash_ref->{League_Assign}; $return_hash{$reg_year}{"LEAGUE_ASSIGN"} = $league_assign; my $num_register_names = $hash_ref->{Num_Register_Names}; $return_hash{$reg_year}{"NUM_REG_NAMES"} = $num_register_names; my $register_type = $hash_ref->{Register_Type}; $return_hash{$reg_year}{"REGISTER_TYPE"} = $register_type; my $test_paypal = $hash_ref->{Test_Paypal}; $return_hash{$reg_year}{"TEST_PAYPAL"} = $test_paypal; my $ok_to_pay_by_check = $hash_ref->{Ok_To_Pay_By_Check}; $return_hash{$reg_year}{"OK_TO_PAY_BY_CHECK"} = $ok_to_pay_by_check; } $sth->finish(); $dbh->disconnect; return %return_hash; } ################################################################ # Get all reg setup info from org id ################################################################ sub get_reg_setup_hash_by_org{ my $org_id = shift; my $dbh = get_dbh(); my %return_hash; ################################################################ # Query DB to verify Session ################################################################ my $query = "SELECT `Secure_URL`, `Org_Dir`, `Reg_File`, `Reg_Admin_File`, `Reg_Year`, `Org_Caps`, `Home_Page_URL`, `Default_State`, `Min_Partial_Pay`, `Reply_To`, `From`, `Org_Full_Name_For_Email`, `Season_Text`, `Welcome_Text`, `Information_Text`, `Pay_Complete_Message`, `Pay_By_Check_Message`, `Paypal_Account`, `Return_URL`, `IPN_URL`, `Paypal_URL`,`Require_Confirmation`, `Require_Confirmation_MSG`, `League_Assign`, `Num_Register_Names`, `Register_Type`, `Test_Paypal`, `Ok_To_Pay_By_Check` FROM `Reg_Setup` WHERE `Org_ID` = '$org_id'"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); while (my $hash_ref = $sth->fetchrow_hashref) { my $reg_year = $hash_ref->{Reg_Year}; my $min_partial_pay = $hash_ref->{Min_Partial_Pay}; $return_hash{$reg_year}{"MIN_PARTIAL_PAY"} = $min_partial_pay; my $org_caps = $hash_ref->{Org_Caps}; $return_hash{$reg_year}{"ORG_CAPS"} = $org_caps; my $reply_to = $hash_ref->{Reply_To}; $return_hash{$reg_year}{"REPLY_TO"} = $reply_to; my $from = $hash_ref->{From}; $return_hash{$reg_year}{"FROM"} = $from; my $org_full_name_for_email = $hash_ref->{Org_Full_Name_For_Email}; $return_hash{$reg_year}{"FULL_NAME"} = $org_full_name_for_email; my $season_text = $hash_ref->{Season_Text}; $return_hash{$reg_year}{"SEASON_TEXT"} = $season_text; my $welcome_text = $hash_ref->{Welcome_Text}; $return_hash{$reg_year}{"WELCOME_TEXT"} = $welcome_text; my $information_text = $hash_ref->{Information_Text}; $return_hash{$reg_year}{"INFORMATION_TEXT"} = $information_text; my $pay_complete_message = $hash_ref->{Pay_Complete_Message}; $return_hash{$reg_year}{"PAY_COMPLETE_MSG"} = $pay_complete_message; my $pay_by_check_message = $hash_ref->{Pay_By_Check_Message}; $return_hash{$reg_year}{"PAY_BY_CHECK_MSG"} = $pay_by_check_message; my $paypal_acc = $hash_ref->{Paypal_Account}; $return_hash{$reg_year}{"PAYPAL_ACC"} = $paypal_acc; my $return_url = $hash_ref->{Return_URL}; $return_hash{$reg_year}{"RETURN_URL"} = $return_url; my $secure_url = $hash_ref->{Secure_URL}; $return_hash{$reg_year}{"SECURE_URL"} = $secure_url; my $reg_file = $hash_ref->{Reg_File}; $return_hash{$reg_year}{"REG_FILE"} = $reg_file; my $reg_admin_file = $hash_ref->{Reg_Admin_File}; $return_hash{$reg_year}{"REG_ADMIN_FILE"} = $reg_admin_file; my $org_dir = $hash_ref->{Org_Dir}; $return_hash{$reg_year}{"ORG_DIR"} = $org_dir; my $thanks_url = "$secure_url/$org_dir/$reg_file?action=pp"; $return_hash{$reg_year}{"THANKS_URL"} = $thanks_url; my $ipn_url = $hash_ref->{IPN_URL}; $return_hash{$reg_year}{"IPN_URL"} = $ipn_url; my $base_reg_url = "$secure_url/$org_dir/$reg_file"; $return_hash{$reg_year}{"BASE_REG_URL"} = $base_reg_url; my $admin_reg_url = "$secure_url/$org_dir/$reg_admin_file"; $return_hash{$reg_year}{"ADMIN_REG_URL"} = $admin_reg_url; my $paypal_url = $hash_ref->{Paypal_URL}; $return_hash{$reg_year}{"PAYPAL_URL"} = $paypal_url; my $default_state = $hash_ref->{Default_State}; $return_hash{$reg_year}{"DEFAULT_STATE"} = $default_state; my $home_page_url = $hash_ref->{Home_Page_URL}; $return_hash{$reg_year}{"HOME_PAGE_URL"} = $home_page_url; my $require_confirmation = $hash_ref->{Require_Confirmation}; $return_hash{$reg_year}{"REQUIRE_CONFIRMATION"} = $require_confirmation; my $require_confirmation_msg = $hash_ref->{Require_Confirmation_MSG}; $return_hash{$reg_year}{"REQUIRE_CONFIRMATION_MSG"} = $require_confirmation_msg; my $league_assign_on = $hash_ref->{League_Assign}; $return_hash{$reg_year}{"LEAGUE_ASSIGN"} = $league_assign; my $num_register_names = $hash_ref->{Num_Register_Names}; $return_hash{$reg_year}{"NUM_REG_NAMES"} = $num_register_names; my $register_type = $hash_ref->{Register_Type}; $return_hash{$reg_year}{"REGISTER_TYPE"} = $register_type; my $test_paypal = $hash_ref->{Test_Paypal}; $return_hash{$reg_year}{"TEST_PAYPAL"} = $test_paypal; my $ok_to_pay_by_check = $hash_ref->{Ok_To_Pay_By_Check}; $return_hash{$reg_year}{"OK_TO_PAY_BY_CHECK"} = $ok_to_pay_by_check; } $sth->finish(); $dbh->disconnect; return %return_hash; } sub get_manage_reg_table_no_reg{ my $menu_table = "
There are currently no active registrations, please
contact getsupport\@hometeamz.com to get started.

\n"; return $menu_table; } sub get_manage_reg_table{ my $start_table = "
\n"; $start_table .= "\n"; $start_table .= ""; #print ""; $start_table .= "\n"; # assign fields to variables my %reg_setup_info = get_reg_setup_hash_by_org($org_id); my $count = 0; my $reg_table = ""; foreach my $reg_year ( keys %reg_setup_info ){ my $test_mode = $reg_setup_info{$reg_year}{"TEST_PAYPAL"}; my $base_reg_url = $reg_setup_info{$reg_year}{"BASE_REG_URL"}; my $admin_reg_url = $reg_setup_info{$reg_year}{"ADMIN_REG_URL"}; my $season_text = $reg_setup_info{$reg_year}{"SEASON_TEXT"}; my $display_test_mode = get_reg_test_mode_for_display($test_mode); $count++; my $reg_row = "\n"; #$reg_row .= "\n"; if($permission_string eq "Webmaster"){ #$reg_row .= "\n"; $reg_row .= "\n"; }else{ #$reg_row .= "\n"; $reg_row .= "\n"; } $reg_row .= "\n"; $reg_row .= "\n"; $reg_row .= "\n"; $reg_table .= $reg_row; } $reg_table .= "
Registration TitleStatusEdit StatusConfigurationUser Registration PageAdmin Registration Page
$season_text$display_test_modeEdit StatusConfigureEdit StatusConfigureOpenOpen
\n"; $reg_table .= "Add Registration
\n"; my $return_table = $start_table . $reg_table; return $return_table; } ################################################################ ### Query how many registrations are active for a given org ################################################################ sub get_num_of_registrations{ my $org_id = shift; my $dbh = get_dbh(); my $query = "SELECT COUNT(*) AS 'REG_COUNT' FROM `Reg_Setup` WHERE `Org_ID` = '$org_id'"; my $sth = $dbh->prepare($query); $sth->execute(); my $reg_count = 0; while ( my $href = $sth->fetchrow_hashref ) { $reg_count = $href->{"REG_COUNT"}; } $sth->finish(); # disconnect from database $dbh->disconnect; return $reg_count; } ################################################################ ### Added to check if user id passed is equal to the param ### associated with session ID ################################################################ sub verify_user_id_param{ my $user_id = shift; my $login_fail_url = shift; my $session_id = get_cookie(); my $session_user_id = get_login_from_session($session_id); if($user_id ne $session_user_id){ print <<__HTML__; __HTML__ exit(1); }else{} } ################################################################ ### If the admin is logged in, print the admin mode page ################################################################ sub print_comm{ my $org_id = shift; my $amdin = shift; my $user = shift; my $pass = shift; my $sub = shift; my $color = "#006699"; my $session_id = 1; my $reg_count = get_num_of_registrations($org_id); my $num_controls = 4; # actual number of controls plus one for loop. my $show_reg = 1; my $tag = param('tag'); if(!(defined($tag))){$tag = 1;} print_comm_header(); if($org_settings{"MODULE_COMM"} == 1){ print <<__HTML__;

My Communications Options
Compose New
Communication
My
History
My Groups
& Contacts
__HTML__ print ""; print ""; print ""; print <<__HTML__; __HTML__ print <<__HTML__; __HTML__ }else{ print "

I'm sorry, you do not have access to the communcations modules. Please contact \@hometeamz.com
\n"; } # assign fields to variables } ########################################### # Print the email history for user ########################################### sub print_compose_comm{ my $org_id = shift; my $user = shift; my $tag = shift; print <<__HTML__;
Compose New Communication
Compose New Communication
__HTML__ print_custom_groups_compose($user, $tag); print <<__HTML__;
Group NameEdit TitleCreated ByDescriptionMembersViewEditRemove
__HTML__ } ########################################### # Print the email history for user ########################################### sub print_manage_groups{ my $user = shift; my $tag = shift; print <<__HTML__;
My Groups & Contacts
Custom Groups
__HTML__ print_custom_groups($user, $tag); print <<__HTML__;
Group NameEdit TitleCreated ByDescriptionMembersViewEditRemove
Create Group
__HTML__ } ################################################## # Get the contents of My Communications History # For Comm Module ################################################## sub print_custom_groups_compose{ my $user_id = shift; my $tag = shift; #my %user_email_history = get_user_email_history($user_id); my $dbh = get_dbh(); my $query = "SELECT `Key`,`Org_ID`,`Group_Name`,`Group_Type`,`Group_Type_ID`, `Desc` FROM `Comm_Groups` WHERE `Owner_ID` = '$user_id' AND `Active` = '1' ORDER BY `Group_Name`"; #print "QUERY: $query\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $html = ""; my $even_odd = 1; my $row_style = "\"cal_event3\""; my $num_groups = 0; while ( my $results = $sth->fetchrow_hashref ){ my $current_key = $results->{Key}; my $group_count = get_group_count($current_key); my $group_name = $results->{Group_Name}; my $current_check_box = "g" . $num_groups; my $view_email_link = ""; if($even_odd == 1){ $row_style = "\"cal_events2\""; $even_odd = 2; }else{ $row_style = "\"cal_events3\""; $even_odd = 1; } $html .= "
$group_nameedit title" . $valid_user{"FIRSTNAME"} . " " . $valid_user{"LASTNAME"} . "" . $results->{Desc} . "$group_countvieweditremove
You currently do not have any active groups.
Click Create Group to get started.
$group_nameedit title" . $valid_user{"FIRSTNAME"} . " " . $valid_user{"LASTNAME"} . "" . $results->{Desc} . "$group_countvieweditremove
You currently do not have any active groups.
Click Create Group to get started.
My Communications History
__HTML__ print_sent_email_table($user); print <<__HTML__;
ViewSentSubjectFromTo# Recipiants# Bounces
__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; } ################################################## # Get the contents of My Communications History # For Comm Module ################################################## sub print_sent_email_table{ my $user_id = shift; #my %user_email_history = get_user_email_history($user_id); my $dbh = get_dbh(); my %user_data = get_user_data($user_id); my %sender_data = get_sender_data($user_id); my $query = "SELECT `Key`, `Org_ID`, `League_ID`, `Team_ID`, `Create_Date`, `Send_Date`, `From_ID`, `Subject`, `Message`, `Context`, `Status`, `Failed` FROM `Comm_Email_Message` WHERE `From_ID` = '$user_id' ORDER BY `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}); if($to eq ""){ $to .= $groups_to; }else{ $to .= "," . $groups_to; } $to =~ s/\,/\, /g; 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} . "" . $user_data{"EMAIL"} . "" . $to . "" . $sender_data{$results->{Key}}{"COUNT"}. "" . $sender_data{$results->{Key}}{"BOUNCE"}. "
Manage Registrations"; } ################################################################ # News is what sub gets set to if there is no sub defined in # the parameter. So to reuse the param, we catch news here. ################################################################ if ($sub eq "news") { $sub = 1; } ################################################################ ### Get the league Name and print the header bar ### i.e. Standing | Calendar | News ################################################################ #$league = get_league_name($league_id); print_admin_header($site_info{"org_short"},$sub,1,$league_id); #$session_id = check_login($user, $pass, $org_id); #$session_id = get_cookie(); if($session_id eq ""){ print_login_block($org_id); #print "Your session has timed out, please login again.
\n"; }else{ print <<__HTML__;


Control Panel
Manage Site Info Manage Pages, Leagues & Menu Manage Gallery Manage Accounts & Permissions Manage Locations/Fields $manage_reg_link

__HTML__ if($fields_mgmt_active != 1){ print <<__HTML__; __HTML__ }else{ print_field_mgmt_admin($org_id); } ############################## # Registration Control Panel ############################## if($show_reg == 1){ print <<__HTML__; __HTML__ }else{ print "\n"; } print <<__HTML__; __HTML__ } #print "\n"; } sub get_reg_test_mode_for_display{ my $test_mode = shift; my $return_string = "Not Active"; if($test_mode == 0){ $return_string = "Active"; }elsif($test_mode == 1){ $return_string = "Test Mode"; } return $return_string; } sub get_permission_string_by_user_id{ my $user_id = shift; my $dbh = get_dbh(); my $query = "SELECT * FROM `Permissions_Info` WHERE `Login_ID` = $user_id"; #print "QUERY: $query
\n"; my %return_hash; my $sth = $dbh->prepare($query); $sth->execute(); my $perm_count = 1; my $current_org = ""; my $current_reg = ""; my $return_string = ""; my $comma = ""; while ( my $href = $sth->fetchrow_hashref ) { my $access_type = $href->{"Access_Type"}; my $access_id = $href->{"Access_ID"}; my $access_level = $href->{"Access_Level"}; if(($access_type eq "ORG")&&($access_id == $org_id)){ if(($current_org eq "")||($current_org eq "R")){ $current_org = $access_level; } }elsif($access_type eq "INFO"){ my ($menu_name, $menu_org) = get_menu_name_and_org_id($access_id); if($menu_org == $org_id){ if($access_level eq "RW"){ $return_string .= $comma . $menu_name; #$return_string .= $comma . $menu_name . " $menu_org " .$access_id; $comma = ", "; } } }elsif(($access_type eq "LEAGUE") || ($access_type eq "TEAM")){ my $league_org = get_org($access_id); #$access_type = "LEAGUE"; if($league_org == $org_id){ #my $menu_key = get_menu_key($access_id); #my $menu_name = get_menu_name($menu_key); #my $menu_name = get_menu_name_by_league_id_and_type($access_id,$access_type, $league_org); my $menu_name = get_menu_for_league_or_team_by_league_id($access_id,$access_type, $league_org); if($access_level eq "RW"){ #$return_string .= $comma . $menu_name . " a " .$access_id; ######################## # Check if the menu_name is blank # this is added to handle any perms for locations # which I found in dev. Not sure about production ######################## if($menu_name ne ""){ $return_string .= $comma . $menu_name; $comma = ", "; } } } }elsif($access_type eq "REG"){ if($access_id == $org_id){ if(($current_reg eq "") || ($current_reg eq "REG2")){ $current_reg = $access_level; } } } #print "TYPE ID: $type_id " . "
\n"; } if($current_reg eq "REG2"){ $return_string .= $comma . "Partial Registration"; }elsif($current_reg eq "REG3"){ $return_string .= $comma . "Full Registration"; } if($return_string eq ""){ $return_string = "[none]"; } if($current_org eq "RW"){ $return_string = "Webmaster"; } $sth->finish(); # disconnect from database $dbh->disconnect; return $return_string; } sub get_users_by_org{ my $org_id = shift; my $dbh = get_dbh(); #my $query = "SELECT * FROM `Permissions_Info` WHERE `Access_Type` = 'ORG' AND `Access_ID` = '$org_id'"; my $query = "SELECT b.`Login`, b.`Firstname`, b.`Lastname`, b.`Key` FROM `Permissions_Info` a, `Account_Info` b WHERE a.`Access_Type` = 'ORG' AND a.`Access_ID` = '$org_id' AND a.`Login_ID` = b.`Key`"; #print "QUERY: $query
\n"; my %return_hash; my $sth = $dbh->prepare($query); $sth->execute(); while ( my $href = $sth->fetchrow_hashref ) { my $login_id = $href->{"Login"}; my $firstname = $href->{"Firstname"}; my $lastname = $href->{"Lastname"}; my $key = $href->{"Key"}; $return_hash{$key}{"LOGIN"} = $login_id; $return_hash{$key}{"FIRSTNAME"} = $firstname; $return_hash{$key}{"LASTNAME"} = $lastname; } $sth->finish(); # disconnect from database $dbh->disconnect; return %return_hash; } sub print_field_mgmt_admin{ print <<__HTML__; __HTML__ } ################################## # Print Admin Org Locations for Subscribtions ################################## sub print_org_subscriber_locations{ my $org_id = shift; my $dbh = get_dbh(); my $count = 0; my $table_contents = ""; ################################## # GET Normal Locations ################################## my $query = "SELECT a.`Key`, a.`Location`, a.`Address_Link`, c.`Org_Full`, d.`Base_URL`, d.`File_Name` FROM `Location_Info` a, `Location_Subscriber_Link` b, `Org_Info` c, `Setup_Info` d WHERE b.`Org_ID` = '$org_id' AND a.`Key` = b.`Location_ID` AND a.`Org_ID` = c.`Key` AND a.`Archived` = 0 AND d.`Org_ID` = a.`Org_ID` ORDER BY a.`Location` ASC"; $sth = $dbh->prepare($query); $sth->execute(); #print "
QUERY: $query
\n"; # assign fields to variables $sth->bind_columns(\$Key, \$Location, \$Address_Link, \$Org_Full, \$Base_URL, \$File_Name); while($sth->fetch()) { $count = 1; my $url = "http://" . $Base_URL . "/" . $File_Name . "?page=field&sub=info&info_id=" . $Key; $table_contents .= "
$Location$Org_Full
\n"; print "\n"; print "\n"; print $table_contents; print "
Subscribed Locations
Field/LocationOwner
\n"; } $sth->finish(); $dbh->disconnect; } ################################## # Print Admin Org Locations ################################## sub print_org_locations{ my $org_id = shift; my $dbh = get_dbh(); ################################## # GET Normal Locations ################################## $query = "SELECT `Key`, `Location`, `Address_Link` FROM `Location_Info` WHERE `Org_ID` = '$org_id' AND Archived = '0' ORDER BY `Location`"; $sth = $dbh->prepare($query); $sth->execute(); #print "
QUERY: $query
\n"; # assign fields to variables $sth->bind_columns(\$Key, \$Location, \$Address_Link); print "\n"; print "\n"; while($sth->fetch()) { print <<__HTML__; __HTML__ } print "
Field/LocationRemoveAdmin
$Location Remove Manage Location
\n"; $sth->finish(); $dbh->disconnect; } ######################################### # Check to see if User has commisioner access ######################################### sub check_access{ my $login_id = shift; my $dbh = get_dbh(); my $commissioner_access = 0; my $Access_Level = ""; # prepare and execute query my $query = "SELECT Access_Level FROM `Permissions_Info` WHERE `Login_ID` = '$login_id'"; #print "$query
\n"; my $sth = $dbh->prepare($query); #print "
$query
\n"; $sth->execute(); # assign fields to variables $sth->bind_columns(\$Access_Level); while($sth->fetch()) { if($Access_Level eq "RW"){ $commissioner_access = 1; } } $sth->finish(); ## disconnect from database $dbh->disconnect; return $commissioner_access; } ######################################### # Check to see if User Name exist ######################################### sub get_user_data{ my $user_id = shift; my $dbh = get_dbh(); my $account_exist = 0; my $return_hash = (); # prepare and execute query my $query = "SELECT * FROM `Account_Info` WHERE `Key` = '$user_id'"; my $sth = $dbh->prepare($query); #print "
$query
\n"; $sth->execute(); # assign fields to variables $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); while($sth->fetch()) { $return_hash{"LOGIN"} = $Login; $return_hash{"EMAIL"} = $email; $return_hash{"FIRSTNAME"} = $Firstname; $return_hash{"LASTNAME"} = $Lastname; $return_hash{"TITLE"} = $Title; $return_hash{"HOMEPHONE"} = $Home_Phone; $return_hash{"WORKPHONE"} = $Work_Phone; $return_hash{"MOBILEPHONE"} = $Mobile_Phone; $return_hash{"ZIP"} = $Zip_Code; $return_hash{"PW"} = $Password; } $sth->finish(); ## disconnect from database $dbh->disconnect; return %return_hash; } ######################################### # Get Toggle Org Settings info ######################################### sub get_org_settings{ my $org_id = shift; my $dbh = get_dbh(); my $org_return_hash = (); # prepare and execute query my $query = "SELECT `Key`, `Show_Ads`, `Subscription_Expiration`, `Current_Status`, `Google_Key`, `Powered_By`, `Module_Field_Mgmt_Lite`, `Module_Field_Mgmt_Full`, `Module_Registration`, `Module_Comm`, `Module_Comm_Reg` FROM `Org_Settings` WHERE `Org_ID` = '$org_id'"; my $sth = $dbh->prepare($query); $sth->execute(); # Set defaults $org_return_hash{"SHOW_ADS"} = 1; $org_return_hash{"SUBSCRIPTION_END_DATE"} = "2036-01-01"; $org_return_hash{"KEY"} = 0; $org_return_hash{"CURRENT_STATUS"} = 1; $org_return_hash{"GOOGLE_KEY"} = ""; $org_return_hash{"POWERED_BY"} = 1; $org_return_hash{"MODULE_FIELD_MGMT_LITE"} = 0; $org_return_hash{"MODULE_FIELD_MGMT_FULL"} = 0; $org_return_hash{"MODULE_REGISTRATION"} = 0; $org_return_hash{"MODULE_COMM"} = 0; $org_return_hash{"MODULE_COMM_REG"} = 0; while (my $hash_ref = $sth->fetchrow_hashref) { $org_return_hash{"SHOW_ADS"} = $hash_ref->{Show_Ads}; $org_return_hash{"SUBSCRIPTION_END_DATE"} = $hash_ref->{Subscription_Expiration}; $org_return_hash{"KEY"} = $hash_ref->{Key}; $org_return_hash{"CURRENT_STATUS"} = $hash_ref->{Current_Status}; $org_return_hash{"GOOGLE_KEY"} = $hash_ref->{Google_Key}; $org_return_hash{"POWERED_BY"} = $hash_ref->{Powered_By}; $org_return_hash{"MODULE_FIELD_MGMT_LITE"} = $hash_ref->{Module_Field_Mgmt_Lite}; $org_return_hash{"MODULE_FIELD_MGMT_FULL"} = $hash_ref->{Module_Field_Mgmt_Full}; $org_return_hash{"MODULE_REGISTRATION"} = $hash_ref->{Module_Registration}; $org_return_hash{"MODULE_COMM"} = $hash_ref->{Module_Comm}; $org_return_hash{"MODULE_COMM_Reg"} = $hash_ref->{Module_Comm_Reg}; } $sth->finish(); ## disconnect from database $dbh->disconnect; return %org_return_hash; } ################################################ ## Return The Information about the site ################################################ sub get_site_info{ my $org_id = shift; my $dbh = get_dbh(); my %site_map = (); # prepare and execute query $query = "SELECT * FROM `Org_Info` WHERE `Key` = $org_id"; $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$Key, \$Org_Short, \$Org_Full, \$Banner_Background_Color, \$Purchased_Leagues, \$Website_Background_Color, \$Banner_Text_Color, \$Site_Logo, \$Site_Banner, \$Site_Banner_Text, \$Site_Banner_Image, \$Message_Box_Background_Color, \$Message_Box_Text_Color, \$Menu_Header_Background_Color, \$Menu_Header_Text_Color, \$Menu_Link_Background_Color, \$Menu_Link_Text_Color, \$Menu_Link_Background_Color_Hover, \$Menu_Link_Text_Color_Hover, \$Menu_Border_Color, \$Menu_Font_Size, \$Menu_Link_Icon); while($sth->fetch()) { $site_map{"org_id"} = $Key; $site_map{"org_short"} = $Org_Short; $site_map{"org_full"} = $Org_Full; $site_map{"site_banner_bg"} = $Banner_Background_Color; $site_map{"purchased_league"} = $Purchased_Leagues; $site_map{"website_bg_color"} = $Website_Background_Color; $site_map{"banner_text_color"} = $Banner_Text_Color; $site_map{"site_logo"} = $Site_Logo; $site_map{"site_banner"} = $Site_Banner; $site_map{"site_banner_text"} = $Site_Banner_Text; $site_map{"site_banner_image"} = $Site_Banner_Image; $site_map{"message_box_bg_color"} = $Message_Box_Background_Color; $site_map{"message_box_text_color"} = $Message_Box_Text_Color; $site_map{"menu_header_bg_color"} = $Menu_Header_Background_Color; $site_map{"menu_header_text_color"} = $Menu_Header_Text_Color; $site_map{"menu_link_bg_color"} = $Menu_Link_Background_Color; $site_map{"menu_link_text_color"} = $Menu_Link_Text_Color; $site_map{"menu_link_bg_color_hover"} = $Menu_Link_Background_Color_Hover; $site_map{"menu_link_text_color_hover"} = $Menu_Link_Text_Color_Hover; $site_map{"menu_border_color"} = $Menu_Border_Color; $site_map{"menu_font_size"} = "$Menu_Font_Size"; $site_map{"menu_icon_link"} = $Menu_Link_Icon; $site_map{"menu_padding"} = "17px"; $site_map{"site_banner_image"} =~ s/\/home\/homete3\/public_html/http:\/\/www.hometeamz.com/; $site_map{"site_logo"} =~ s/\/home\/homete3\/public_html/http:\/\/www.hometeamz.com/; } if(!(defined($site_map{"menu_font_size"}))){$site_map{"menu_font_size"} = "11";} $sth->finish(); # disconnect from database $dbh->disconnect; ### These fields were added, just make sure they are not blank :) if($site_map{"menu_link_text_color"} eq "") {$site_map{"menu_link_text_color"} = "#ffffff";} if($site_map{"menu_link_bg_color"} eq "") {$site_map{"menu_link_bg_color"} = "#999999";} if($site_map{"menu_link_text_color_hover"} eq ""){$site_map{"menu_link_text_color_hover"} = "#ffffff";} if($site_map{"menu_link_bg_color_hover"} eq "") {$site_map{"menu_link_bg_color_hover"} = "#686b6e";} if($site_map{"menu_border_color"} eq "") {$site_map{"menu_border_color"} = "#ffffff";} if($site_map{"menu_header_text_color"} eq "") {$site_map{"menu_header_text_color"} = "#ffffff";} if($site_map{"menu_header_bg_color"} eq "") {$site_map{"menu_header_bg_color"} = "#686b6e";} if($site_map{"menu_font_size"} == 0) {$site_map{"menu_font_size"} = "11";} if($site_map{"message_box_text_color"} eq "") {$site_map{"message_box_text_color"} = $site_map{"banner_text_color"};} if($site_map{"message_box_bg_color"} eq "") {$site_map{"message_box_bg_color"} = $site_map{"site_banner_bg"};} if($site_map{"menu_icon_link"} eq "") {$site_map{"menu_padding"} = "10px";} return %site_map; } sub print_tournament{ my $league_id = shift; my $text = "Tournaments"; my $width = 200; print <<__HTML__;
$text
__HTML__ %tournaments = get_current_tournaments($league_id); foreach $tournament_id (sort keys %tournaments) { print "$tournaments{$tournament_id}
\n"; } print <<__HTML__;
__HTML__ } sub print_options_coach{ my $league_id = shift; my %divisions = get_divisions($league_id); my %teams = get_league_teams_w_division($league_id); my %season_duration = get_season_duration($league_id); my $league_name = get_league_name($league_id); my $num_divs = 0; my $show_warning_message = 0; my $menu_type = get_league_menu_type($league_id, $org_id); print <<__HTML__; __HTML__ print "

\n"; print "
\n"; if($menu_type eq "team"){ print <<__HTML__;
Update Team Name
__HTML__ foreach $key (keys %teams){ $team = $key; } print "
\n"; print "\n"; print "\n"; print "\n"; print "
Team NameEdit
$team
edit
\n"; print "
\n"; }elsif($menu_type eq "league"){ print <<__HTML__;
Update League Name
__HTML__ print "
\n"; print "\n"; print "\n"; print "\n"; print "
Team NameEdit
$league_name
edit
\n"; print "
\n"; } print <<__HTML__;
Season Duration
Set your current Season's date range below. Note, games outside the Season Duration date range will not be factored into the Standings or appear on the Print Season button.
__HTML__ my $season_has_expired = check_if_season_has_expired($season_duration{"Season_ED"}); print "
\n"; print "\n"; print "\n"; print "\n"; print "
Season Start DateSeason End Date
$season_duration{\"Season_SD\"}
$season_duration{\"Season_ED\"}
\n"; #print "
\n"; print "Edit Season Duration\n"; if($season_has_expired == 1){ print "
!!! Warning. Your Season Duration has expired. Any game results entered outside this date range will not appear in the Standings. Also, any calendar events entered outside this date range will not appear in the user's Print Season view !!!
\n"; } print "
\n"; if($menu_type ne "team"){ # print <<__HTML__;
Divisions
__HTML__ print "
\n"; print "\n"; print "\n"; foreach $key (sort {lc($divisions{$a}) cmp lc($divisions{$b})} keys %divisions){ print "\n"; $num_divs++; } print "
DivisionEditRemove
$divisions{$key}editremove
Add New Division\n"; print "
\n"; print <<__HTML__;
\n"; } print "
Teams
__HTML__ print "
\n"; print "
\n"; print "\n"; print "\n"; foreach $key (keys %teams){ $div_id = $teams{$key}{"Division_ID"}; $team = $key; $team_id = $teams{$key}{$key}; ##### Check if there are no divisions if(!(defined($divisions{$div_id}))){ $divisions{$div_id} = ""; } if(($num_divs > 0) && ($divisions{$div_id} eq "")){ print "\n"; $show_warning_message = 1; }else{ print "\n"; } } print "
TeamDivisionEditRemove
$key$divisions{$div_id}editremove
$key$divisions{$div_id}editremove
Add New Team
\n"; if ($show_warning_message) { print "
Warning! Teams not assigned to any existing division will not appear in the standings. Please use the edit option to add a team(s) in red to a division
\n"; print <<__HTML__;
__HTML__ }else{ my %linked_leagues = get_linked_leagues2($league_id); print <<__HTML__;
League Subscriptions
__HTML__ print "
\n"; print "\n"; print "\n"; foreach my $linked_league_id (keys %linked_leagues) { $league = get_league_name($linked_league_id); $linked_org = get_org_full_from_league($linked_league_id); $linked_url = get_org_url_from_league($linked_league_id); my %teamsa = get_league_teams($linked_league_id); my %teams = (); foreach $team_key (keys %teamsa) { $teams{$teamsa{$team_key}} = $team_key; } if($linked_leagues{"$linked_league_id"}{"LINKED_TEAM_ID"} == 0){ print "\n"; }else{ my $linked_to_team_id = $linked_leagues{"$linked_league_id"}{"LINKED_TEAM_ID"}; print "\n"; } #This one opens widow, but only works if its in the same league #print "\n"; } print "
Subscribed to LeagueLeague OwnerTeamEdit TeamRemove
$league$linked_orgNAEditRemove
$league$linked_org$teams{\"$linked_to_team_id\"}EditRemove
$leagueTeamRemove
\n"; print "
Subscribe
to League

\n"; #This one opens widow, but only works if its in the same league #print "Link to League
standings

\n"; } if($menu_type ne "team"){ my %display_name_map = ( "PCT" => "PCT", "WINS" => "W", "TIES" => "T", "LOSSES" => "L", "Team Name" => "Team Name", "PF" => "PF", "PA" => "PA", "POINTS" => "PTS", "POINTSB" => "PTS" ); print <<__HTML__;
Standings
Use the table below to configure which stats to display and hide in the Standings page.
__HTML__ my %standings_type = get_league_standings_type($league_id); my $standings_enabled_message = ""; if($standings_type{"ENABLED"} == 1){ $standings_enabled_message = "Standings are currently enabled.             "; $enable_standings_message = "enable
standings"; $disable_stadnings_message = "disable
standings
"; }else{ $standings_enabled_message = "Standings are currently disabled.             "; $enable_standings_message = "enable
standings
"; $disable_stadnings_message = "disable
standings"; } print "
\n"; print "
\n"; print "\n"; print "\n"; print "
$standings_enabled_message $enable_standings_message $disable_stadnings_message
\n"; print <<__HTML__;
__HTML__ print <<__HTML__;
Team Standings - Display
Use the table below to configure which stats to display and hide in the Standings page.
__HTML__ print "
\n"; print "
\n"; print "\n"; print "\n"; @display_on_off = ("hidden","displayed"); #my %standings_type = get_league_standings_type($league_id); for(my $i=1; $i<9; $i++){ my $j = $i + 1; my $stat_name = $standings_type{"D". $i}; my $next_name = $standings_type{"D". $j}; my $stat_desc = $standings_type{$stat_name . "-desc"}; #print"START NAME: $stat_name - $i
\n"; my $move_left = "move left"; my $move_right = "move right"; if($i == 1){ $move_left = "move left"; } if(($i == 8)||($standings_type{$next_name} == 0)){ $move_right = "move right"; } if($standings_type{$stat_name} == 1){ print "\n"; }else{ #print "\n"; print "\n"; } } print "
StatDescriptionDisplayHide/UnhideMove
$display_name_map{$stat_name}$stat_descdisplayedhideunhide$move_left$move_right
$d1$d1_desc$display_on_off[$standings_type{$d1}]remove
$display_name_map{$stat_name}$stat_deschiddenhideunhidemove leftmove right
\n"; print <<__HTML__;
Team Standings - Sort Order
Use the table below to configure how standings are calculated.
__HTML__ print "
\n"; print "
\n"; print "\n"; print "\n"; @display_sort_order = ("do not user","low-to-high","high-to-low"); #my %standings_type = get_league_standings_type($league_id); for(my $i=1; $i<=9; $i++){ my $j = $i + 1; my $stat_name = $standings_type{"P". $i}; my $next_name = $standings_type{"P". $j}; my $stat_desc = $standings_type{$stat_name . "-desc"}; my $move_up = "move up"; my $move_down = "move down"; if($i == 1){ $move_up = "move up"; } if(($i == 9)||($standings_type{$next_name . "-sort"} == 0)){ $move_down = "move down"; } if($standings_type{$stat_name . "-sort"} == 0){ print "\n"; }elsif($standings_type{$stat_name . "-sort"} == 1){ print "\n"; }else{ print "\n"; } } print "
StatDescriptionSort OrderChange Sort OrderChange Priority
$display_name_map{$stat_name}$stat_descdo not usehigh-to-lowlow-to-highdo not usemove upmove down
$display_name_map{$stat_name}$stat_desclow-to-highhigh-to-lowlow-to-highdo not use $move_up$move_down
$display_name_map{$stat_name}$stat_deschigh-to-lowhigh-to-lowlow-to-highdo not use$move_up$move_down
\n"; print <<__HTML__;
__HTML__ ###################################### # Schedule Management - JM 1/20/2009 ###################################### print <<__HTML__;
Schedule Management
Use this function to clear all calendar events (games, practices, league events, tournaments, etc.) to help set-up a new season. Warning - clearing schedules is not recoverable.
__HTML__ #print "
\n"; #print "\n"; #print "\n"; # print "\n"; #print "
Season Start DateSeason End Date
$season_duration{\"Season_SD\"}
$season_duration{\"Season_ED\"}
\n"; #print "
\n"; #print " print "
Clear Schedules\n"; print "Use this function to bulk load a new season's schedule from an Excel spreadsheet or Scheduler export. To download the Excel spreadsheet template and instructions, click HERE\n"; print "
Upload Schedules\n"; print "
\n"; ###################################### # END Schedule Management - JM 1/20/2009 ###################################### } # END IF Not team page print "\n"; } sub get_linked_leagues{ my $league_id = shift; my $dbh = get_dbh(); my @return_array = (); # prepare and execute query my $query = "SELECT `League_Standings_ID` FROM `League_Standings_Link` WHERE `Team_ID` = $league_id;"; #print "QUERY:$query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$League_Standings_ID); ################################################ ## Loop through News Items ################################################ while($sth->fetch()) { push(@return_array, $League_Standings_ID); } $sth->finish(); $dbh->disconnect; return @return_array; } sub get_linked_leagues2{ my $league_id = shift; my $dbh = get_dbh(); my %return_hash = (); # prepare and execute query my $query = "SELECT `Key`, `Team_ID`, `League_Standings_ID`, `Linked_Team_ID` FROM `League_Standings_Link` WHERE `Team_ID` = $league_id;"; #print "QUERY:$query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Key, \$Team_ID, \$League_Standings_ID, \$Linked_Team_ID); ################################################ ## Loop through News Items ################################################ while($sth->fetch()) { $return_hash{"$League_Standings_ID"}{"KEY"} = $Key; $return_hash{"$League_Standings_ID"}{"LINKED_TEAM_ID"} = $Linked_Team_ID; } $sth->finish(); $dbh->disconnect; return %return_hash; } sub get_default_team_for_team_only_league{ my $league_id = shift; my $dbh = get_dbh(); my %return_hash = (); # prepare and execute query my $query = "SELECT `Key` FROM `Team_Info` WHERE `League_ID` = $league_id;"; #print "QUERY:$query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Key); ################################################ ## Loop through News Items ################################################ while($sth->fetch()) { $return_id = $Key; } $sth->finish(); $dbh->disconnect; return $return_id; } sub print_tournament_coach{ my $league_id = shift; print <<__HTML__;


Tournaments
__HTML__ print "
\n"; print "
\n"; print "\n"; print "\n"; # assign fields to variables %tournaments = get_current_tournaments($league_id); foreach $tournament_id (sort keys %tournaments) { print "\n"; print "\n"; } print "
TournamentsViewEditRemove
$tournaments{$tournament_id}ViewEditRemove
\n"; print "
\n"; print "Create New Bracket\n"; print <<__HTML__;
__HTML__ } ################################################################ ### If a League is selected, this is what handle where to go ################################################################ sub print_league{ my $league = shift; my $month = shift; my $year = shift; my $org_id = shift; my $league_id = shift; my $coach = shift; my $filter = shift; my $color = "#006699"; my $menu_type = get_league_menu_type($league_id, $org_id); ################################################################ ### Get the league Name and print the header bar ### i.e. Standing | Calendar | News ################################################################ $league = get_league_name($league_id); print_league_header($league,$sub,0,$league_id); ################################################################ ### This is just to push the text down a bit ################################################################ print "
\n"; #print "
Hi There!      

\n"; ################################################################ ### Determine whether to print the news, standing or calendar ################################################################ if($sub eq 'news'){ print_news($league, $org_id, $league_id, $color, 0); }elsif($sub eq 'standings'){ my $menu_type = get_league_menu_type($league_id, $org_id); if($menu_type ne "team"){ print_standings($league, $org_id, $league_id, 0); }else{ @linked_leagues = get_linked_leagues($league_id); my $first = 1; foreach(@linked_leagues){ $league = get_league_name($_); $linked_org = get_org_full_from_league($_); $linked_url = get_org_url_from_league($_); print_linked_event_header("Standings", $league, $linked_url, $linked_org, $first); print_standings("NOT SURE", 0, $_, 0); $first = 0; } if($first == 1){ print "

No Standings available for this Team
\n"; } } }elsif($sub eq 'calendar'){ print_league_calendar($league, $month, $year, 0, $org_id, $league_id, $filter, $menu_type); }elsif($sub eq 'tournament'){ print "
\n"; print_tournament($league_id); @linked_leagues = get_linked_leagues($league_id); foreach(@linked_leagues){ $league = get_league_name($_); $linked_org = get_org_full_from_league($_); $linked_url = get_org_url_from_league($_); print_linked_event_header("Tournaments", $league, $linked_url, $linked_org); print_tournament($_); } print "\n"; } ################################################################ ### Not sure where this div starts???? ################################################################ print "\n"; } sub print_linked_event_header{ my $event_type = shift; my $league = shift; my $linked_url = shift; my $league_org = shift; my $first = shift; my $hr_text = "
"; if ($first == 1) { $hr_text = ""; } print <<__HTML__;

$hr_text
$event_type for $league League
League $event_type Managed by $linked_org
__HTML__ } ################################################################ ### If a League is selected, this is what handle where to go ################################################################ sub print_league_only{ my $league = shift; my $month = shift; my $year = shift; my $org_id = shift; my $league_id = shift; my $coach = shift; my $filter = shift; my $color = "#006699"; ################################################################ ### Get the league Name and print the header bar ### i.e. Standing | Calendar | News ################################################################ $league = get_league_name($league_id); print_league_only_header($league,$sub,0,$league_id); ################################################################ ### This is just to push the text down a bit ################################################################ print "

\n"; ################################################################ ### Determine whether to print the news, standing or calendar ################################################################ if($sub eq 'news'){ print_news($league, $org_id, $league_id, $color, 0); }elsif($sub eq 'standings'){ print_standings($league, $org_id, $league_id, 0); }elsif($sub eq 'calendar'){ print_league_calendar($league, $month, $year, 0, $org_id, $league_id, $filter); }elsif($sub eq 'tournament'){ print_tournament($league_id); } print "\n"; print "\n"; print "\n"; print "\n"; print <<__HTML__;
\n"; } return $Show_Alert, $html; } sub get_alert_notification_js{ my $location_id = shift; my $show_hide = shift; my $dbh = get_dbh(); my $html = ""; my $display_form = "display:block"; if($show_hide eq "hidden"){ $display_form = "display:none"; } my $query = "SELECT `Show_Alert`, `Alert_Message` FROM `Location_Subscriber_Message` WHERE `Location_ID` = '$location_id'"; #print $query, "
\n"; my $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Show_Alert, \$Alert_Message); $already_exist = 0; $subscription_count = 0; $checked = ""; while($sth->fetch()) { if($Show_Alert > 0){ $checked = "CHECKED"; } $org_short = get_org_short($Org_ID); $message = $Alert_Message; $message =~ s/'/\\'/g; } $sth->finish(); $dbh->disconnect; if($Show_Alert > 0){ my $location_name = get_location_name($location_id); my $org_full = get_location_owner_full($location_id); my $org_url = get_org_url_from_location($location_id); $html .= "
"; $html .= ""; $html .= ""; $html .= ""; $html .= "
$message"; $html .= "

"; #$html .= ""; #$html .= "
"; #$html .= "
"; } return $Show_Alert, $html; } sub get_location_owner_full{ my $key = shift; my $dbh = get_dbh(); #my $query = "SELECT b.`Org_Short` FROM `Location_Subscriber_Link` a, `Org_Info` b WHERE a.`Key` = '$key' AND a.`Org_ID` = b.`Key`"; my $query = "SELECT b.`Org_Full` FROM `Location_Info` a, `Org_Info` b WHERE a.`Key` = '$key' AND a.`Org_ID` = b.`Key`"; #print $query, "
\n"; my $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Org_Full); $already_exist = 0; $subscription_count = 0; while($sth->fetch()) { $org_full = $Org_Full; } $sth->finish(); $dbh->disconnect; return $org_full; } 1;