################################################################ ### This sub will get all the event from the database give ### a date, team, and league and print them to the screen ################################################################ ############# Filter On - Team specific sub get_field_events_for_full_calendar_month{ my $start_date = shift; my $end_date = shift; my $league = shift; my $current_month = shift; my $current_year = shift; my $coach = shift; my $org_id = shift; my $field_id = shift; my $filter = shift; my $am_pm = ""; my $display_time = ""; my $last_date = ""; my $count = 0; my $even = 1; my %return_hash = (); #print "\n"; #print "\n"; #print "\n"; #print "\n"; ################################################ ## Copy Teams Hash so that Keys=Value ## And for Locations ## This was down becuase orginally the query ## was created so that the hash vaule was the ## field, but in this instance it needs to be ## the other way around. ################################################ my %locations = get_locations_with_link($org_id); my %eventsa = get_event_types(); #foreach $key (keys %locationsa){ # $locations{$locationsa{$key}} = $key; #} foreach $key (keys %eventsa){ $events{$eventsa{$key}} = $key; } $events{"5"} = "Tournament Game"; my $dbh = get_dbh(); # prepare and execute query $location_id = $filter; my $query = "SELECT * FROM `Calendar_Events` WHERE `Start_Date` > '$start_date' AND `Start_Date` < '$end_date' AND `Location` = $field_id ORDER BY Start_Date ASC"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $Status = 0; # assign fields to variables $sth->bind_columns(\$ID, \$Org_ID, \$League_ID, \$Team_ID, \$Start_Date, \$End_Date, \$Event_Type, \$Home_Team, \$Home_Score, \$Away_Team, \$Away_Score, \$Desc, \$Location, \$Other_Location, \$Notes, \$Status); while($sth->fetch()) { ################################################ ## Parse Date String ################################################ my ($date, $time) = split(/\s+/, $Start_Date); my ($hour,$min,$sec) = split(/:/, $time); my ($current_year,$month,$day) = split(/-/, $date); my $shortened_notes = substr($Notes,0,20); my $leftover_notes = substr($Notes,20); my %date_time_hash = get_date_string_for_fields($Start_Date, $End_Date); my $day_name = $date_time_hash{"DAY_NAME"}; my $month_name = $date_time_hash{"MONTH_NAME"}; $display_time = $date_time_hash{"DISPLAY_TIME"}; $display_time = lc($display_time); $display_time =~ s/\s+//g; $edisplay_time = $date_time_hash{"END_DISPLAY_TIME"}; $edisplay_time = lc($edisplay_time); $edisplay_time =~ s/\s+//g; $month = $date_time_hash{"MONTH"}; $day = $date_time_hash{"DAY"}; $date = $date_time_hash{"DATE"}; ################################################ # Get Org Name to display ################################################ my $org_name = get_org_short($Org_ID); my $league = get_league_name($League_ID); #my %teamsa = get_league_teams($League_ID); #foreach $key (keys %teamsa){ # $teams{$teamsa{$key}} = $key; #} $month = sprintf("%02d", $month); $date_key = $current_year . "_" . $month . "_" . $day; my $league_url = get_org_url_from_league($League_ID); $league_url = "http://" . $league_url . "/?org_id=$Org_ID&page=league&league_id=$League_ID&sub=calendar&month=$current_month&year=$current_year&filter=0"; my $org_string = ""; if($Org_ID != $org_id){ $org_string = "$org_name - $league"; }else{ $org_string = "$league"; } my $event_description = $events{$Event_Type}; if($events{$Event_Type} eq "League Event"){$event_description = $Desc;} my $strike_start = ""; my $strike_end = ""; if($Status == 1){ $strike_start = ""; $strike_end = ""; } if(defined($return_hash{$date_key})){ $return_hash{$date_key} = $return_hash{$date_key} . "$display_time-$edisplay_time
" . $strike_start . $org_string . ", $event_description" . $strike_end . "

"; }else{ $return_hash{$date_key} = $strike_start . "$display_time-$edisplay_time
" . $org_string . ", $event_description" . $strike_end ."

"; } } $sth->finish(); # disconnect from database $dbh->disconnect; return %return_hash; } sub get_next_sunday { my $current_month = shift; my $current_year = shift; my $current_day = shift; my $next_prev = shift; my $return_string = 0; my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst); $month = $current_month; $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); if($wday == 0){$wday = 1;} while($wday != 0){ if($next_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; $year = $year + 1900; return $month,$year,$day; } ################################################################ ### Get the day of week (mon, tue, etc) ### Inputs: Month day year ### Return: Day of the week ################################################################ sub get_day_of_week2 { 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_calendar prints a calendar as a table give month and ### year ################################################################ sub print_field_calendar_week { my $current_month = shift; my $current_year = shift; my $field_id = shift; my $coach = shift; my $start_day = param('start_day'); my $first_day_of_month = 0; my $last_day_of_month = 0; weekly_style(); if(!(defined($coach))){ $coach = 0; } if(!(defined($current_month))){ $current_date = get_date(); ($current_month, $current_day, $current_year) = split(/\//, $current_date); } ($next_month, $next_year) = get_next_month($current_month, $current_year, "next"); $current_month = sprintf("%02d", $current_month); $next_month = sprintf("%02d", $next_month); $start_date = "$current_year-$current_month-01 00:00:00"; $end_date = "$next_year-$next_month-01 00:00:00"; if(!(defined($start_day))){ $start_day = 1; $day = 1; } $filter = 1; $day_count = 1; my %field_events_full_cal = get_field_events_for_full_calendar_month($start_date, $end_date, $league, $current_month, $current_year, $coach, $org_id, $field_id, $filter); #print "


CM: $current_month - CY: $current_year - $field_id - $coach
\n"; print "


\n"; #print_field_header2($current_month,$current_year,$field_id,$coach,$filter); print_calendar_header_week($current_month,$current_year,$field_id,$form,$input_name, $start_day); ($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_week = get_day_of_week($current_month, $start_day, $current_year); if($first_day_of_week != 0){ for($i=$first_day_of_week;$i>0;$i--){ $day_count++; my $day_offset = $i + $start_day -1; my $date_key = $current_year . "_" . $current_month . "_" . $day_offset; print "$day_offset - $date_key
\n"; #print_extra_day_week($current_month,$current_year,"previous",$day_offset,1,$league, $coach, $field_events_full_cal{$date_key}, $field_id); } } my %weekly_events = (); my @days_in_week = (); ### Loop through the days of the month to print them for($i=$start_day;$i<=$current_last;$i++){ #print "$current_month/$i/$current_year\n"; my $day_offset = $i; my $date_key = $current_year . "_" . $current_month . "_" . $i; $date_key = "$current_month/$i/$current_year"; #print "$date_key
\n"; if($day_count < 8){ push(@days_in_week, $date_key); my %content = get_current_schedule_for_week_view($date_key, $field_id, $org_id); foreach my $date_key2 (keys %content) { foreach my $time (keys %{$content{$date_key2}}) { $weekly_events{$date_key}{$time} = $content{$date_key2}{$time}; } } #print_calendar_day_week($current_month, $i, $current_year, "white", $league, $coach, $content, $field_id); #print_calendar_day_week($current_month, $i, $current_year, "white", $league, $coach, $field_events_full_cal{$date_key}, $field_id); } $day_count++; } ### 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++){ my $day_offset = $i + $start_day; my $date_key = $current_year . "_" . $current_month . "_" . $day_offset; if($day_count < 8){ #print_extra_day_week($current_month,$current_year,"following",$i,$current_last,$league,$coach, $field_events_full_cal{$date_key}, $field_id); } $day_count++; } } my $border = "1px solid #aaaab6"; my $day_of_week_style = "message_box"; my $day_of_week_border = "style='border-left:$border;border-top:$border;'"; my $day_of_week_border_last = "style='border-left:$border;border-top:$border;border-right:$border;'"; @hours = ("12 AM", "1 AM", "2 AM","3 AM","4 AM","5 AM","6 AM", "7 AM","8 AM","9 AM","10 AM","11 AM","12 PM","1 PM","2 PM","3 PM","4 PM","5 PM","6 PM","7 PM","8 PM","9 PM","10 PM","11 PM"); foreach(@hours){ my $time = $_; print "$time\n"; foreach(@days_in_week) { my $show_date = ""; if($time eq "12 AM"){ $show_date = "$_
"; } $cell_bg = "#ffffff"; if ($weekly_events{$_}{$time} =~ m/busy/) { $cell_bg = "#cecece"; } #print "$show_date
\n"; print "$show_date\n"; } print "\n"; } print_calendar_footer(); } ################################################################ ### print_calendar prints a calendar as a table give month and ### year ################################################################ sub print_field_calendar { my $current_month = shift; my $current_year = shift; my $field_id = shift; my $coach = shift; my $printable = shift; if(!(defined($printable))){ $printable = 0; } my $first_day_of_month = 0; my $last_day_of_month = 0; if(!(defined($coach))){ $coach = 0; } if(!(defined($current_month))){ $current_date = get_date(); ($current_month, $current_day, $current_year) = split(/\//, $current_date); } 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"); $prev_month = sprintf("%02d", $prev_month); $current_month = sprintf("%02d", $current_month); $next_month = sprintf("%02d", $next_month); $start_date = "$prev_year-$prev_month-21 00:00:00"; $end_date = "$next_year-$next_month-07 00:00:00"; $filter = 1; my %field_events_full_cal = get_field_events_for_full_calendar_month($start_date, $end_date, $league, $current_month, $current_year, $coach, $org_id, $field_id, $filter); #print "


CM: $current_month - CY: $current_year - $field_id - $coach
\n"; print "


\n"; #print_field_header2($current_month,$current_year,$field_id,$coach,$filter); if($printable == 1){ print_calendar_header_printable($current_month,$current_year,$field_id,$form,$input_name); }else{ print_calendar_header_full($current_month,$current_year,$field_id,$form,$input_name); } my ($current_last,$current_last_dow) = get_last_day($current_month, $current_year); my ($prev_last,$prev_last_dow) = get_last_day($prev_month, $prev_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); ######################################## # Print Days before current month ######################################## if($first_day_of_month != 0){ for($i=$first_day_of_month;$i>0;$i--){ my $prev_month_day = $prev_last - $i + 1; my $date_key = $prev_year . "_" . $prev_month . "_" . $prev_month_day; #print "$date_key
\n"; print_extra_day_full($current_month,$current_year,"previous",$i,1,$league, $coach, $field_events_full_cal{$date_key}, $field_id); } } ######################################## # Print Days of current month ######################################## for($i=1;$i<=$current_last;$i++){ #print "$current_month/$i/$current_year\n"; my $date_key = $current_year . "_" . $current_month . "_" . $i; #print "$date_key
\n"; print_calendar_day_full($current_month, $i, $current_year, "white", $league, $coach, $field_events_full_cal{$date_key}, $field_id); } ######################################## # Print Days of 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++){ my $date_key = $next_year . "_" . $next_month . "_" . $i; #print "$date_key - $end_date
\n"; print_extra_day_full($current_month,$current_year,"following",$i,$current_last,$league,$coach, $field_events_full_cal{$date_key}, $field_id); } } print_calendar_footer(); } ################################################################ ### print_calendar_day is used to print any day given the ### day, month and year ################################################################ sub print_calendar_day_week { my $current_month = shift; my $current_day = shift; my $current_year = shift; my $bgcolor = shift; my $league = shift; my $coach = shift; my $content = shift; my $field_id = shift; $coach = 1; if($content eq ""){ $content = "

\n"; } 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 "$content"; #} print " \n"; if($wday == 6){ #my ($prev_month,$prev_year,$prev_day) = get_next_sunday($current_month, $current_year, $current_day, "prev"); #print " View Week\n"; print " \n"; } } ################################################################ ### print_calendar_day is used to print any day given the ### day, month and year ################################################################ sub print_calendar_day_full { my $current_month = shift; my $current_day = shift; my $current_year = shift; my $bgcolor = shift; my $league = shift; my $coach = shift; my $content = shift; my $field_id = shift; $coach = 1; my $style = "day_of_week_full_cal"; if($bgcolor eq "#dcdcdc"){ $style = "day_of_week_full_cal_gray"; } if($content eq ""){ $content = "

\n"; } 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 "$content"; #} print " \n"; if($wday == 6){ my ($prev_month,$prev_year,$prev_day) = get_next_sunday($current_month, $current_year, $current_day, "prev"); #print "\n"; #print "\n"; This was for week view print " \n"; } } ################################################################ ### print_extra_day is used to print the days before and ### after the month to fill the calendar - This is for small cal ################################################################ sub print_extra_day_week { 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 $field_id = 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_week($month, $day, $year, "gray", $league, $coach, "", $field_id); #print "$month/$day/$year\n"; } ################################################################ ### print_extra_day is used to print the days before and ### after the month to fill the calendar - This is for small cal ################################################################ sub print_extra_day_full { 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 $content = shift; my $field_id = 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_full($month, $day, $year, "#dcdcdc", $league, $coach, "$content", $field_id); #print "$month/$day/$year\n"; } ################################################################ # Print some shared JS for calendar stuff ################################################################ sub print_field_calendar_js{ my $sub_cat = shift; my $current_month = shift; my $current_year = shift; my $coach = shift; my $field_id = shift; print <<__HTML__; __HTML__ } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header_week { my $current_month = shift; my $current_year = shift; my $field_id = shift; my $form = shift; my $input_name = shift; my $day = shift; my $file_name = "print_cal.pl"; my $bgcolor = "#006699"; my $border = "2px solid #aaaab6"; my $day_of_week_style = "message_box"; my $day_of_week_border = "style='border-left:$border;border-top:$border;'"; my $day_of_week_border_last = "style='border-left:$border;border-top:$border;border-right:$border;'"; print_field_calendar_js("week", $current_month, $current_year, $coach, $field_id); my $current_month_name = get_month_name_small($current_month); my ($next_month,$next_year,$next_day) = get_next_sunday($month, $year, $day, "next"); my ($prev_month,$prev_year,$prev_day) = get_next_sunday($month, $year, $day, "prev"); print "
\n"; print "
Print Month\n"; print "View Field Info
"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; %fields = get_locations_with_link_no_archived($org_id); print "  
<<     $current_month_name $current_year     >>
\n"; print "  \n"; print "
\n"; #print "\n"; print "\n"; } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header_printable { my $current_month = shift; my $current_year = shift; my $field_id = shift; my $form = shift; my $input_name = shift; my $file_name = "print_cal.pl"; my $bgcolor = "#006699"; my $border = "2px solid #aaaab6"; my $day_of_week_style = "message_box"; my $current_month_name = get_month_name_small($current_month); #my $day_of_week_border = "style='border-left:1px solid black;border-top:1px solid black;'"; my $day_of_week_border = "style='border-left:$border;border-top:$border;'"; #my $day_of_week_border_last = "style='border-left:1px solid black;border-top:1px solid black;border-right:1px solid black;'"; my $day_of_week_border_last = "style='border-left:$border;border-top:$border;border-right:$border;'"; #print_field_calendar_js("fullcal", $current_month, $current_year, $coach, $field_id); print '
SundayMondayTuesdayWednesdayThursdayFridaySaturday
 SundayMondayTuesdayWednesdayThursdayFridaySaturday 
Print Schedule
'; print "\n"; print "\n"; %fields = get_locations_with_link_no_archived($org_id); my $field_name = $fields{$field_id}{"Location"}; #print "Location: $field_name"; print ""; print "\n"; } ################################################################ ### print_calendar_header is used to start the calendar ################################################################ sub print_calendar_header_full { my $current_month = shift; my $current_year = shift; my $field_id = shift; my $form = shift; my $input_name = shift; my $file_name = "print_cal.pl"; my $bgcolor = "#006699"; my $border = "2px solid #aaaab6"; my $day_of_week_style = "message_box"; #my $day_of_week_border = "style='border-left:1px solid black;border-top:1px solid black;'"; my $day_of_week_border = "style='border-left:$border;border-top:$border;'"; #my $day_of_week_border_last = "style='border-left:1px solid black;border-top:1px solid black;border-right:1px solid black;'"; my $day_of_week_border_last = "style='border-left:$border;border-top:$border;border-right:$border;'"; print_field_calendar_js("fullcal", $current_month, $current_year, $coach, $field_id); 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 "
Location: $field_name     Team: All Teams     Time:  $current_month_name  $current_year
SundayMondayTuesdayWednesdayThursdayFridaySaturday
\n"; print "\n"; print "\n"; print "
Print Month\n"; print "View Field Info
"; #print "\n"; #print "\n"; #print ""; }else{ $address_link_cell = ""; } $output_line = "\n"; $output_line .= "$address_link_cell \n"; $output_line .= "\n"; return $output_line; } sub get_field_list_row_style{ my $even = shift; if($even){ $row_style = "cal_events2"; $even--; }else{ $row_style = "cal_events3"; $even++; } return ($row_style, $even); } sub print_field_list{ my $org_id = shift; my %field_info = get_field_info($org_id); my $even_odd = 1; $field_header = "date_header"; #print "

\n"; print "\n"; print "\n"; print "\n"; #print "\n"; print "\n"; #print "\n"; print "
\n"; %fields = get_locations_with_link_no_archived($org_id); print "  
<<     $current_month_name $current_year     >>
<<     $current_month_name $current_year     >>
\n"; print "\n"; print "  \n"; print "
\n"; print "\n"; #print "\n"; This was extra for week view } ################################################################ ### If a League is selected, this is what handle where to go ################################################################ sub print_field{ my $month = shift; my $year = shift; my $sub = shift; my $coach = shift; #my $field_id = param('info_id'); my $field_id = shift;; if ($sub eq "") { $sub = "list"; } $location_name = get_location_name($field_id); if($sub eq "calendar"){ print_field_header($month, $year, $coach, $location_name, $field_id); print_field_calendar_list($month, $year, $coach, $org_id, $field_id, $filter, $menu_type); }elsif($sub eq "list"){ $menu_name = get_menu_name($field_id); print_field_list_header($org_id, $menu_name); print_field_list($org_id); }elsif($sub eq "info"){ print_field_info($org_id, $field_id, $coach); }elsif($sub eq "fullcal"){ print_field_header($month, $year, $coach, $location_name, $field_id); print_field_calendar($month, $year, $field_id, $coach, 0); }elsif($sub eq "week"){ print_field_header($month, $year, $coach, $location_name, $field_id); print_field_calendar_week($month, $year, $field_id, $coach); } } sub print_field_info{ my $org_id = shift; my $field_key = shift; my %field_info = get_field_info($org_id); my $even_odd = 1; $field_header = "date_header"; print_field_info_header($org_id, $field_key, $field_info{$field_key}{"LOCATION"}, $coach); print <<__HTML__; __HTML__ #print "

SundayMondayTuesdayWednesdayThursdayFridaySaturday 
\n"; print "

$field_info{$field_key}{\"LOCATION\"}
\n"; print "\n"; #print "\n"; if($coach == 1){ print "
$field_info{$field_key}{\"LOCATION\"}
\n"; print "
Edit Field Location
\n"; print "
\n"; }else{ print "
\n"; } print "\n"; print "\n"; if($field_info{$field_key}{"ADDRESS_LINK"} ne ""){ print "\n"; }else{ print "\n"; } print "\n"; print "
$field_info{$field_key}{\"LOCATION\"}
Address:$field_info{$field_key}{\"ADDRESS\"}
Map Link:
Map Link:
Calendar Link:
\n"; print "
\n"; #print "\n"; #print "\n"; #print "
Status:
Status Notes:NA
Last Updated:NA
\n"; print "
           
\n"; #Used to be NA row print "
\n"; print "
\n"; $field_information = $field_info{$field_key}{"DIRECTIONS"}; # Overloaded directions with this if($coach == 1){ print "
\n"; print "
Edit Field Location Info
\n"; print "
\n"; }else{ print "
\n"; } if($field_information eq ""){$field_information = "No information available for $field_info{$field_key}{\"LOCATION\"}";} print_field_info_block2($field_information); print "
\n"; print "
\n"; print "
\n"; } ################################################################ ### Print the normal news block (HTML portion) ################################################################ sub print_field_info_block2{ my $text = shift; my $color = $site_info{"message_box_bg_color"}; my $text_color = $site_info{"message_box_text_color"}; 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"; } ##############################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; #$text = "hello"; print <<__HTML__;
$text


__HTML__ } sub get_info_id_from_field_id{ my $field_id = shift; my $return_val = 0; $dbh = get_dbh(); %fields = (); # prepare and execute query $query = "SELECT `Key` FROM `Menu_Info` WHERE `Org_ID` = $org_id AND `League_ID` = '$field_id' AND `Menu_Type` = 'location'"; #print "QUERY: $query
\n"; $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Key); while($sth->fetch()) { $return_val = $Key; } $sth->finish(); # disconnect from database $dbh->disconnect; return $return_val; } ################################################################# ## Print the Update Field Information Block for one item ################################################################# sub print_update_field_info_block{ my $org_id = shift; my $field_id = shift; my $color = shift; my $page_type = shift; my $info_id = get_info_id_from_field_id($field_id); my $message = ""; if($info_id != 0){ $info_id_hidden_value = ""; $message = ""; }else{ $message = "The location you are editing is not completely registered, some features may not work."; } my %field_info = get_field_info($org_id); #my %info_info = get_info_info2($ID); #my ($date, $time) = split(/\s+/,$info_info{"Date"}); #my $date = convert_date_to_display($date); my $date = get_date(); $info_info{"Text"} =~ s/
/\n/g; $info_info{"Text"} =~ s/http:\/\/www.hometeamz.com\/teamdata\//\/teamdata\//g; #$info_info{"Text"} =~ s/\/teamdata\//\/teamdata\//g; #$info_info{"Text"} =~ s/hometeamzhometeamz/hometeamz/g; print <<__HTML__;

$info_id_hidden_value
$message
  update
__HTML__ } ################################################################ ### Print the top menu bar ################################################################ sub print_field_info_header{ my $org_id = shift; my $field_key = shift; my $location_name = shift; $display_header_string = "$location_name"; $top_menu = "top_menu"; $more_top_menu = "more_top_menu"; print <<__HTML__;
$display_header_string __HTML__ print "\n"; if($coach){ print "Logout\n"; }else{ print "Admin\n"; #print "Admin\n"; } print "
\n"; print "
\n"; print "
\n"; } sub get_field_list_row{ my $even_odd = shift; my $field_key = shift; my $org_id = shift; my $location = shift; my $address = shift; my $address_link = shift; my $directions = shift; my $order = shift; my $address_link_cell = ""; ($row_style, $even) = get_field_list_row_style($even); if($address_link eq ""){ $address_link_cell = "
  $location $addressView Info
\n"; print "

\n"; }else{ $edit_cell = ""; } } } $league = get_league_name($League_ID); if($org_id != $Org_ID){ my $org_name = get_org_short($Org_ID); my $league_url = get_org_url_from_league($League_ID); $league_url = "http://" . $league_url . "/?org_id=$Org_ID&page=league&league_id=$League_ID&sub=calendar&month=$current_month&year=$current_year&filter=0"; $program_cell = ""; }else{ $program_cell = ""; } print " " . $events_description . $program_cell . $notes_cell . $edit_cell ."\n"; ################################################ # Keep count of how many events displayed ################################################ $count++; } print "
\n"; #print "\n"; #print "
\n"; print "
\n"; print "\n"; foreach my $field_key (sort {$field_info{$a}{"LOCATION"} cmp $field_info{$b}{"LOCATION"}}keys %field_info) { ($field_row, $even_odd) = get_field_list_row($even_odd, $field_key, $field_info{$field_key}{"ORG_ID"}, $field_info{$field_key}{"LOCATION"}, $field_info{$field_key}{"ADDRESS"}, $field_info{$field_key}{"ADDRESS_LINK"}, $field_info{$field_key}{"DIRECTIONS"}); print $field_row; #print "\n"; #print "\n"; #print "\n"; #print "\n"; #print "\n"; #print "\n"; #print "\n"; #print "\n"; } print "
LocationAddress View 
Info
Map
  Link  
  Calendar  
$field_info{$field_key}{\"ORG_ID\"}$field_info{$field_key}{\"LOCATION\"}$field_info{$field_key}{\"ADDRESS\"}$field_info{$field_key}{\"ADDRESS_LINK\"}$field_info{$field_key}{\"DIRECTIONS\"}$field_info{$field_key}{\"ORDER\"}
\n"; print "
\n"; } sub get_field_info{ my $org_id = shift; $dbh = get_dbh(); %fields = (); # prepare and execute query $query = "SELECT * FROM `Location_Info` WHERE `Org_ID` = $org_id AND `Archived` = '0'"; $sth = $dbh->prepare($query); $sth->execute(); # assign fields to variables $sth->bind_columns(\$Key, \$Org_ID, \$Location, \$Address, \$Address_Link, \$Directions, \$Order, \$Archived); while($sth->fetch()) { $fields{$Key}{"ORG_ID"} = $Org_ID; $fields{$Key}{"LOCATION"} = $Location; $fields{$Key}{"ADDRESS"} = $Address; $fields{$Key}{"ADDRESS_LINK"} = $Address_Link; $fields{$Key}{"DIRECTIONS"} = $Directions; $fields{$Key}{"ORDER"} = $Order; } $sth->finish(); # disconnect from database $dbh->disconnect; return %fields; } ################################################################ ### Print the top menu bar ################################################################ sub print_field_list_header{ my $org_id = shift; my $page_header = shift; $coach = 0; if($coach){ $top_menu = "top_menu"; $more_top_menu = "more_top_menu"; $display_header_string = "Field View"; }else{ $top_menu = "top_menu"; $display_header_string = "Field View"; $more_top_menu = "more_top_menu"; } print <<__HTML__;
$page_header
__HTML__ } ################################################################ ### This sub will get all the event from the database give ### a date, team, and league and print them to the screen ################################################################ ############# Filter On - Team specific sub get_field_events{ my $start_date = shift; my $end_date = shift; my $league = shift; my $current_month = shift; my $current_year = shift; my $coach = shift; my $org_id = shift; my $field_id = shift; my $filter = shift; my $am_pm = ""; my $display_time = ""; my $last_date = ""; my $count = 0; my $even = 1; print "\n"; print "\n"; print "\n"; print "\n"; ################################################ ## Copy Teams Hash so that Keys=Value ## And for Locations ## This was down becuase orginally the query ## was created so that the hash vaule was the ## field, but in this instance it needs to be ## the other way around. ################################################ my %locations = get_locations_with_link($org_id); my %eventsa = get_event_types(); #foreach $key (keys %locationsa){ # $locations{$locationsa{$key}} = $key; #} foreach $key (keys %eventsa){ $events{$eventsa{$key}} = $key; } $events{"5"} = "Tournament Game"; ################################################ ## Print Main Calendar Header ## in pyb_lib.pm ################################################ print_field_header2($current_month,$current_year,$field_id,$coach,$filter); my $dbh = get_dbh(); # prepare and execute query $location_id = $filter; my $query = "SELECT * FROM `Calendar_Events` WHERE `Start_Date` > '$start_date' AND `Start_Date` < '$end_date' AND `Location` = $field_id ORDER BY Start_Date ASC"; #print "QUERY: $query
\n"; my $sth = $dbh->prepare($query); $sth->execute(); my $Status = 0; # assign fields to variables $sth->bind_columns(\$ID, \$Org_ID, \$League_ID, \$Team_ID, \$Start_Date, \$End_Date, \$Event_Type, \$Home_Team, \$Home_Score, \$Away_Team, \$Away_Score, \$Desc, \$Location, \$Other_Location, \$Notes, \$Status); while($sth->fetch()) { ################################################ ## Parse Date String ################################################ my ($date, $time) = split(/\s+/, $Start_Date); my ($hour,$min,$sec) = split(/:/, $time); my ($current_year,$month,$day) = split(/-/, $date); my $shortened_notes = substr($Notes,0,20); my $leftover_notes = substr($Notes,20); my %date_time_hash = get_date_string_for_fields($Start_Date, $End_Date); my $day_name = $date_time_hash{"DAY_NAME"}; my $month_name = $date_time_hash{"MONTH_NAME"}; $display_time = $date_time_hash{"DISPLAY_TIME"}; $edisplay_time = $date_time_hash{"END_DISPLAY_TIME"}; $month = $date_time_hash{"MONTH"}; $day = $date_time_hash{"DAY"}; $date = $date_time_hash{"DATE"}; my %teamsa = get_league_teams($League_ID); foreach $key (keys %teamsa){ $teams{$teamsa{$key}} = $key; } ################################################ ## Set current location var and take into account ## that the Other location could be set ################################################ if($Location == 0){ #Location is other $current_location = $Other_Location; }else{ if($locations{$Location}{"LINK"} ne ""){ $current_location = "" . $locations{$Location}{"Location"} . ""; }else{ $current_location = $locations{$Location}{"Location"}; } } ################################################ # Get Org Name to display ################################################ my $org_name = get_org_short($Org_ID); ################################################ # Print Date Row if new Date ################################################ if($last_date ne $date){ if($coach){ $colspan = 7; }else{ $colspan = 6; } $date_row = get_date_row($month_name, $day, $current_year, $day_name, $colspan, 0); print $date_row . "\n"; $last_date = $date; } #$Status = 1; ($row_style, $even) = get_row_style($even, $Status); $notes_cell = get_notes_cell($Notes, $row_style, $ID); my $home_team_to_pass = $teams{$Home_Team}; my $away_team_to_pass = $teams{$Away_Team}; ############################# # Add support so that tourney show teams ############################# if($Event_Type == 5){ my %tournament_event_info = get_tournament_event_info_by_event_id($ID); my $alt_top = $tournament_event_info{"ALT_TOP_BRACKET"}; my $alt_bottom = $tournament_event_info{"ALT_BOTTOM_BRACKET"}; if($Home_Team == 0){ if($alt_top ne ""){ $home_team_to_pass = $alt_top; }else{ $home_team_to_pass = "TBD"; } } if($Away_Team == 0){ if($alt_bottom ne ""){ $away_team_to_pass = $alt_bottom; }else{ $away_team_to_pass = "TBD"; } } }else{ ################################################ ## Check to see if other team is used. ################################################ if($Home_Team == 0){ my %team_event_info = get_team_event_info_by_event_id($ID); $home_team_to_pass = $team_event_info{"ALT_HOME_TEAM"}; } if($Away_Team == 0){ my %team_event_info = get_team_event_info_by_event_id($ID); $away_team_to_pass = $team_event_info{"ALT_AWAY_TEAM"}; } } $events_description = get_events_description($Event_Type, $Desc, $home_team_to_pass, $Home_Score, $away_team_to_pass, $Away_Score); $edit_cell = ""; if($coach){ if($event_type == 5){ }else{ if($org_id == $Org_ID){ $edit_cell = "
Edit "; $edit_cell .= "Del"; $edit_cell .= "
Cancel
Edit Del
Cancel
$org_name - $league$league
$display_time$edisplay_time$events{$Event_Type}
\n"; $sth->finish(); # disconnect from database $dbh->disconnect; if($count == 0){ print "

No events for schedule for this field this month.
\n"; } } ################################################################ ### Sets up the print area for the calendar (does not do much) ################################################################ sub print_field_calendar_list{ my $current_month = shift; my $current_year = shift; my $coach = shift; my $org_id = shift; my $field_id = shift; my $filter = shift; my $menu_type = shift; if(!(defined($coach))){ $coach = 0; } if(!(defined($current_month))){ $current_date = get_date(); ($current_month, $current_day, $current_year) = split(/\//, $current_date); } ($next_month, $next_year) = get_next_month($current_month, $current_year, "next"); $current_month = sprintf("%02d", $current_month); $next_month = sprintf("%02d", $next_month); $start_date = "$current_year-$current_month-01 00:00:00"; $end_date = "$next_year-$next_month-01 00:00:00"; #$league = 1; if($coach){ print "

\n"; print "\n"; } print "


\n"; $filter = 1; get_field_events($start_date, $end_date, $league, $current_month, $current_year, $coach, $org_id, $field_id, $filter); print "
\n"; } ################################################################ ### Print the top menu bar ################################################################ sub print_field_header{ my $month = shift; my $year = shift; my $coach = shift; my $location_name = shift; my $field_id = shift; if($coach){ $top_menu = "top_menu"; $more_top_menu = "more_top_menu"; $display_header_string = "Field View"; }else{ $top_menu = "top_menu"; $display_header_string = "Field View"; $more_top_menu = "more_top_menu"; } print <<__HTML__;
Field View $location_name __HTML__ 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_calendar_header is used to start the calendar ################################################################ sub print_field_header2 { my $current_month = shift; my $current_year = shift; my $field_id = shift; my $coach = shift; my $filter = shift; my $season = "2005"; my $border = "1px solid #aaaab6"; my $col_header_style = "message_box"; my $col_header_border = "style='border-left:$border;border-top:$border;'"; my $col_header_border_last = "style='border-left:$border;border-top:$border;border-right:$border;'"; print_field_calendar_js("calendar", $current_month, $current_year, $coach, $field_id); ################################################################ # 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"; #print "\n"; print "
    $season Season    
\n"; print "
Print Month\n"; print "View Field Info
"; #print "\n"; #print "
League Events\n"; print "
\n"; #print "\n"; print "
\n"; print "\n"; if($coach){ $coach_string = "&coach=1"; $colspan = 3; $colspan2 = 7; $edit_title = ""; $notes_border = $col_header_border; }else{ $coach_string = ""; $colspan = 2; $colspan2 = 6; $edit_title = ""; $notes_border = $col_header_border_last; } print "\n"; print "
 \n"; %fields = get_locations_with_link_no_archived($org_id); print "  Admin\n"; print "
<<<   \n"; print "$minus_two_month_name   \n"; print "$prev_month_name   \n"; print "$current_month_name   \n"; print "$next_month_name   \n"; print "$plus_two_month_name   \n"; print ">>>
\n"; print "
\n"; print "  \n"; print "
"; #print "$edit_title\n"; print "$edit_title\n"; } sub get_locations_with_link_no_archived{ my $Org_ID = shift; my $dbh = get_dbh(); # prepare and execute query my $query = "SELECT * FROM Location_Info WHERE Org_ID = $Org_ID AND Archived = 0 ORDER BY Location ASC"; my $sth = $dbh->prepare($query); my %return_hash = (); my $ID; my $Location; $sth->execute(); # assign fields to variables $sth->bind_columns(\$ID, \$Org_ID, \$Location, \$Address, \$Address_Link, \$Directions, \$Order, \$Archived); # output name list to the browser while($sth->fetch()) { $return_hash{$ID}{"Location"} = $Location; $return_hash{$ID}{"LINK"} = $Address_Link; } $sth->finish(); # disconnect from database $dbh->disconnect; return %return_hash; } sub get_date_string_for_fields{ my $Start_Date = shift; my $End_Date = shift; my %return_hash = (); ################################################ ## Parse Date String ################################################ my ($date, $time) = split(/\s+/, $Start_Date); my ($hour,$min,$sec) = split(/:/, $time); my ($edate, $etime) = split(/\s+/, $End_Date); my ($ehour,$emin,$esec) = split(/:/, $etime); my ($current_year,$month,$day) = split(/-/, $date); my ($ecurrent_year,$emonth,$eday) = split(/-/, $edate); ################################################ ## Convert to epoch seconds and back to get ## Day of week (ie Sat) and to get the Day ## without any leading zero's (ie 03) ################################################ my $time_in_epoch = timelocal($sec,$min,$hour,$day,$month-1,$current_year-1900); my ($rsec, $rmin, $rhour, $current_day, $rmonth, $ryear, $wday, $yday, $isdst) = localtime($time_in_epoch); my $etime_in_epoch = timelocal($esec,$emin,$ehour,$eday,$emonth-1,$ecurrent_year-1900); my ($ersec, $ermin, $erhour, $ecurrent_day, $ermonth, $eryear, $ewday, $eyday, $eisdst) = localtime($etime_in_epoch); ################################################ ## Convert to Month Name (ie January) and ## Day of Week name (ie Sat) ################################################ my $day_name = get_day_name($wday); my $month_name = get_month_name($month); ################################################ ## Make conversions to display properly ################################################ if($rhour > 12){ $rhour = $rhour - 12; $am_pm = "PM"; }elsif($rhour == 0){ $rhour = 12; $am_pm = "AM"; }elsif($rhour == 12){ $am_pm = "PM"; }else{ $am_pm = "AM"; } if($erhour > 12){ $erhour = $erhour - 12; $eam_pm = "PM"; }elsif($erhour == 0){ $erhour = 12; $eam_pm = "AM"; }elsif($erhour == 12){ $eam_pm = "PM"; }else{ $eam_pm = "AM"; } my $display_time = "$rhour:$min $am_pm"; my $edisplay_time = "$erhour:$emin $eam_pm"; $return_hash{"DISPLAY_TIME"} = $display_time; $return_hash{"END_DISPLAY_TIME"} = $edisplay_time; $return_hash{"DAY_NAME"} = $day_name; $return_hash{"MONTH_NAME"} = $month_name; $return_hash{"MONTH"} = sprintf("%1d",$month); $return_hash{"DAY"} = sprintf("%1d",$day); $return_hash{"DATE"} = $date; return %return_hash; } sub get_row_style{ my $even = shift; my $Status = shift; if($even){ if($Status == 1){ $row_style = "cal_events2_st"; $row_style_notes = "cal_events2"; }else{ $row_style = "cal_events2"; $row_style_notes = "cal_events2"; } $even--; }else{ if($Status == 1){ $row_style = "cal_events3_st"; $row_style_notes = "cal_events3"; }else{ $row_style = "cal_events3"; $row_style_notes = "cal_events3"; } $even++; } return ($row_style, $even); } sub get_date_row { my $month_name = shift; my $day = shift; my $current_year = shift; my $day_name = shift; my $colspan = shift; my $coach = shift; my $border = "1px solid #aaaab6"; my $date_row_style = "style='border-left:$border;border-top:$border;border-right:$border;;border-bottom:$border;'"; my $return_string = " \n"; #$return_string .= " \n"; return $return_string; } sub get_notes_cell{ my $Notes = shift; my $row_style = shift; my $ID = shift; my $shortened_notes = substr($Notes,0,20); my $leftover_notes = substr($Notes,20); my $return_string = ""; if($Notes ne ""){ if(length($Notes) > 20){ $return_string .= " \n"; }elsif($Home_Score < $Away_Score){ $return_string .= "\n"; }else{ $return_string .= "\n"; } }else{ $return_string .= "\n"; } }elsif($event_type == 2){ $return_string .= "\n"; }else{ $return_string .= "\n"; } return $return_string; } sub get_tournament_team_name{ # not finished!!!! my $ID = shift; my $Home_Team = shift; my $Away_Team = shift; ################################################ ## Check if its a tournament event ################################################ %tournament_event_info = get_tournament_event_info_by_event_id($ID); $alt_top = $tournament_event_info{"ALT_TOP_BRACKET"}; $alt_bottom = $tournament_event_info{"ALT_BOTTOM_BRACKET"}; if($Home_Team == 0){ if($alt_top ne ""){ $teams{'0'} = $alt_top; }else{ $teams{'0'} = "TBD"; } } if($Away_Team == 0){ if($alt_bottom ne ""){ $teams{'-1'} = $alt_bottom; }else{ $teams{'-1'} = "TBD"; } $Away_Team = -1; } if($Notes eq ""){ $Notes = $tournament_event_info{"ALT_TEXT"}; } $events{$Event_Type} = "Tournament Game"; } sub weekly_style{ my $busy_color = "#cecece"; print <<__HTML__; __HTML__ } sub get_current_schedule_for_week_view{ my $date = shift; my $location = shift; my $other = ""; my $org_id = shift; my $league_id = ""; my $event_id = ""; my %sched_busy = (); my $html = ""; my %locations = get_locations_with_link($org_id); my %eventsa = get_event_types(); #my %teamsa = get_league_teams($league_id); #foreach $key (keys %teamsa){ # $teams{$teamsa{$key}} = $key; #} foreach $key (keys %eventsa){ $events{$eventsa{$key}} = $key; } my $was_busy = 0; my $was_available = 0; my ($current_month, $current_day, $current_year) = split(/\//, $date); my $dow = get_day_of_week($current_month, $current_day, $current_year); my $day_name = get_day_name($dow); my $month_name = get_month_name($current_month); my $dbh = get_dbh(); my $start_date = "$current_year-$current_month-$current_day 00:00:01"; my $end_date = "$current_year-$current_month-$current_day 23:59:59"; # prepare and execute query my $query = "SELECT * FROM `Calendar_Events` WHERE `Start_Date` > '$start_date' AND `Start_Date` < '$end_date' AND `Location` = $location ORDER BY Start_Date ASC"; my $sth = $dbh->prepare($query); #$html .= $query . "
\n"; $sth->execute(); # assign fields to variables $sth->bind_columns(\$ID, \$Org_ID, \$League_ID, \$Team_ID, \$Start_Date, \$End_Date, \$Event_Type, \$Home_Team, \$Home_Score, \$Away_Team, \$Away_Score, \$Desc, \$Location, \$Other_Location, \$Notes, \$Status); while($sth->fetch()) { if($Status != 1) { my %teams = get_org_teams($Org_ID); #$html .= "EVENT: $ID
\n"; ################################################ ## Parse Date String ################################################ my ($date, $time) = split(/\s+/, $Start_Date); my ($hour,$min,$sec) = split(/:/, $time); my ($current_year,$month,$day) = split(/-/, $date); my ($edate, $etime) = split(/\s+/, $End_Date); my ($ehour,$emin,$esec) = split(/:/, $etime); my ($ecurrent_year,$emonth,$eday) = split(/-/, $edate); ################################################ ## Convert to epoch seconds and back to get ## Day of week (ie Sat) and to get the Day ## without any leading zero's (ie 03) ################################################ my $time_in_epoch = timelocal($sec,$min,$hour,$day,$month-1,$current_year-1900); my ($rsec, $rmin, $rhour, $current_day, $rmonth, $ryear, $wday, $yday, $isdst) = localtime($time_in_epoch); my $etime_in_epoch = timelocal($esec,$emin,$ehour,$eday,$emonth-1,$ecurrent_year-1900); my ($resec, $remin, $rehour, $ecurrent_day, $remonth, $reyear, $ewday, $eyday, $eisdst) = localtime($etime_in_epoch); ################################################ ## Convert to Month Name (ie January) and ## Day of Week name (ie Sat) ################################################ #my $day_name = get_day_name($wday); # these are set below, probably ok to remove but left for now #my $month_name = get_month_name($month); # these are set below, probably ok to remove ################################################ ## Make conversions to display properly ################################################ if($rhour > 12){ $rhour = $rhour - 12; $am_pm = "PM"; }elsif($rhour == 0){ $rhour = 12; $am_pm = "AM"; }elsif($rhour == 12){ $am_pm = "PM"; }else{ $am_pm = "AM"; } my %date_time_hash = get_date_string_for_fields($Start_Date, $End_Date); my $day_name = $date_time_hash{"DAY_NAME"}; my $month_name = $date_time_hash{"MONTH_NAME"}; $display_time = $date_time_hash{"DISPLAY_TIME"}; $display_time = lc($display_time); $edisplay_time = $date_time_hash{"END_DISPLAY_TIME"}; $edisplay_time = lc($edisplay_time); $month = $date_time_hash{"MONTH"}; $day = $date_time_hash{"DAY"}; $date = $date_time_hash{"DATE"}; $league_name = get_league_name($League_ID); #$league_name = "$league_name $League_ID $ID"; $org_short = get_org_short($Org_ID); my $org_string = ""; if($Org_ID != $org_id){$org_string = "$org_short, ";} my $event_description = $events{$Event_Type}; if($events{$Event_Type} eq "League Event"){$event_description = $Desc;} my $strike_start = ""; my $strike_end = ""; if($Status == 1){ $strike_start = ""; $strike_end = ""; } #if(defined($return_hash{$date_key})){ # $return_hash{$date_key} = $return_hash{$date_key} . $strike_start . $org_string ."$league, $event_description, $display_time - $edisplay_time" . $strike_end . "

"; #}else{ # $return_hash{$date_key} = $strike_start . $org_string . "$league, $event_description, $display_time - $edisplay_time" . $strike_end ."

"; #} ################################################ ## Check to see if other team is used. ################################################ %team_event_info = get_team_event_info_by_event_id($ID); if($Home_Team == 0){ $display_home = $team_event_info{"ALT_HOME_TEAM"}; }else{ $display_home = $teams{$Home_Team}; } if($Away_Team == 0){ $display_away = $team_event_info{"ALT_AWAY_TEAM"}; }else{ $display_away = $teams{$Away_Team}; } if($Event_Type == 4){ #$busy_string = "     $events{$Event_Type} ($league_name, $display_away @ $display_home, $org_short)"; $busy_string = $strike_start . $org_string . "$league_name, $event_description, $display_time - $edisplay_time" . $strike_end; }elsif($Event_Type == 3){ #$busy_string = "     $events{$Event_Type} ($league_name, $display_away @ $display_home, $org_short)"; $busy_string = $strike_start . $org_string . "$league_name, $event_description, $display_time - $edisplay_time" . $strike_end; }elsif($Event_Type == 2){ #$busy_string = "     $events{$Event_Type} ($league_name, $display_home, $org_short)"; $busy_string = $strike_start . $org_string . "$league_name, $event_description, $display_time - $edisplay_time" . $strike_end; }elsif($Event_Type == 1){ #$busy_string = "     $events{$Event_Type} ($league_name, $Desc , $org_short)"; $busy_string = $strike_start . $org_string . "$league_name, $event_description, $display_time - $edisplay_time" . $strike_end; }elsif($Event_Type == 5){ %tournament_event_info = get_tournament_event_info_by_event_id($ID); $alt_top = $tournament_event_info{"ALT_TOP_BRACKET"}; $alt_bottom = $tournament_event_info{"ALT_BOTTOM_BRACKET"}; if($Home_Team == 0){ $display_home = $alt_top; }else{ $display_home = $teams{$Home_Team}; } if($Away_Team == 0){ $display_away = $alt_bottom; }else{ $display_away = $teams{$Away_Team}; } #$busy_string = "     Tournament Game ($league_name, $display_away @ $display_home, $org_short)"; $busy_string = $strike_start . $org_string . "$league_name, $event_description, $display_time - $edisplay_time" . $strike_end; }elsif($Event_Type == 6){ if(!(defined($sched_busy{"$rhour:$rmin:$am_pm"}))){ #$busy_string = "##    $events{$Event_Type} ($league_name, $org_short)"; $busy_string = $strike_start . $org_string . "$league_name, $event_description, $display_time - $edisplay_time" . $strike_end; } } if($event_id != $ID){ $sched_busy{"$rhour:$rmin:$am_pm"} = "$busy_string"; }else{ $sched_busy{"$rhour:$rmin:$am_pm"} = "-"; } #$html .= "BUSY: $rhour:$min:$am_pm
\n"; my $found_end_time = 0; while($found_end_time == 0){ my $zam_pm = ""; $time_in_epoch = $time_in_epoch + (60*15); if($time_in_epoch < $etime_in_epoch){ #$html .= "TIME: $time_in_epoch
\n"; #$html .= "ETIME: $etime_in_epoch
\n"; #$html .= "$time_in_epoch
\n"; my ($zsec, $zmin, $zhour, $zcurrent_day, $zmonth, $zyear, $zday, $zday2, $zsdst) = localtime($time_in_epoch); if($zhour > 12){ $zhour = $zhour - 12; $zam_pm = "PM"; }elsif($zhour == 0){ $zhour = 12; $zam_pm = "AM"; }elsif($zhour == 12){ $zam_pm = "PM"; }else{ $zam_pm = "AM"; } if($Event_Type == 6){ if($event_id != $ID){ if(!(defined($sched_busy{"$zhour:$zmin:$zam_pm"}))){ $sched_busy{"$zhour:$zmin:$zam_pm"} = "##    $events{$Event_Type} ($league_name, $org_short)"; } }else{ $sched_busy{"$zhour:$zmin:$zam_pm"} = "-"; } }else{ if($event_id != $ID){ $sched_busy{"$zhour:$zmin:$zam_pm"} = " "; }else{ $sched_busy{"$zhour:$zmin:$zam_pm"} = "-"; } } #$html .= "BUSY: $zhour:$zmin:$zam_pm
\n"; }else{ $found_end_time = 1; } } } } #$sched_busy{"$rhour:$min:$am_pm"} = 1; ################################################ ## Set current location var and take into account ## that the Other location could be set ################################################ if($Location == 0){ #Location is other $current_location = $Other_Location; %sched_busy = (); }else{ if($locations{$Location}{"LINK"} ne ""){ $current_location = "" . $locations{$Location}{"Location"} . ""; }else{ $current_location = $locations{$Location}{"Location"}; } } my ($next_month, $next_year, $next_day) = get_next_day($current_month, $current_year, $current_day, "next"); my ($prev_month, $prev_year, $prev_day) = get_next_day($current_month, $current_year, $current_day, "prev"); $current_day = sprintf("%1d",$current_day); $next_day = sprintf("%02d",$next_day); $next_month = sprintf("%02d",$next_month); $prev_day = sprintf("%02d",$prev_day); $prev_month = sprintf("%02d",$prev_month); #if($other ne ""){ # $html .= "
Location: $other
\n"; #}else{ # $html .= "
Location: $locations{$location}{\"Location\"}
\n"; #} #$html .= "<<\n"; #$html .= "Date: $day_name $month_name $current_day, $current_year\n"; #$html .= ">>
\n"; @hours = ("12 AM", "1 AM", "2 AM","3 AM","4 AM","5 AM","6 AM", "7 AM","8 AM","9 AM","10 AM","11 AM","12 PM","1 PM","2 PM","3 PM","4 PM","5 PM","6 PM","7 PM","8 PM","9 PM","10 PM","11 PM"); @quarter = (0,15,30,45); $ampm_count = 0; #$html .= "
\n"; $html .= "
\n"; #$html2 .= "
Start TimeEnd TimeEvent TypeEvent DescriptionProgramNotes
Start TimeEnd TimeEvent TypeEvent DescriptionProgramNotes
\n"; $return_string .= " \n"; if($coach){ $return_string .= "  $month_name $day, $current_year ($day_name)\n"; }else{ $return_string .= " $month_name $day, $current_year ($day_name)\n"; } $return_string .= "
$shortened_notes...[+]
\n"; $return_string .= " \n"; }else{ $return_string .= "
$shortened_notes\n"; } }else{ $return_string .= "  \n"; } return $return_string; } sub get_events_description { my $event_type = shift; my $Desc = shift; my $Home_Team = shift; my $Home_Score = shift; my $Away_Team = shift; my $Away_Score = shift; my $return_string = ""; # 5 = tournament 3 = Preseason 2 = practice 1 = League Event 4 = Game if(($event_type == 5)||($event_type == 3)||($event_type == 4)){ if(($Home_Score != -1) && ($Away_Score != -1)){ #-1 = game is not played yet if($Home_Score > $Away_Score){ $return_string .= "$Away_Team($Away_Score) @ $Home_Team($Home_Score) $Away_Team($Away_Score) @ $Home_Team($Home_Score) $Away_Team($Away_Score) @ $Home_Team($Home_Score) $Away_Team @ $Home_Team $Home_Team$Desc
\n"; %return_hash = (); foreach(@hours){ my $time = $_; my ($hour, $ampm) = split(/\s+/,$time); #$html2 .= "\n"; } $html .= "
$time\n"; $html2 .= "
$time\n"; #$html .= "
    \n"; $html .= "
      \n"; $quarter_count = 0; if($ampm eq "PM"){ $ampm_count = 1; } my $hourly_html = ""; foreach(@quarter){ my $quarter = $_; my $li_id = "$hour$quarter$ampm_count"; $display_quarter = sprintf("%02d",$quarter); $display_quarter = " "; if(!(defined($sched_busy{"$hour:$quarter:$ampm"}))){ $sched_busy{"$hour:$quarter:$ampm"} = ""; } if($sched_busy{"$hour:$quarter:$ampm"} ne ""){ if($sched_busy{"$hour:$quarter:$ampm"} eq " "){ $hourly_html .= "
    • $display_quarter $sched_busy{\"$hour:$quarter:$ampm\"}
    • "; $was_available = 0; }elsif($sched_busy{"$hour:$quarter:$ampm"} eq "-"){ $hourly_html .= "
    • $display_quarter
    • "; $was_busy = 0; $was_available = 0; }elsif($sched_busy{"$hour:$quarter:$ampm"} =~ m/\#\#/){ $sched_busy{"$hour:$quarter:$ampm"} =~ s/\#\#//; if($was_available == 1){ $sched_busy{"$hour:$quarter:$ampm"} = ""; } #$html .= "
    • $display_quarter $sched_busy{\"$hour:$quarter:$ampm\"}
    • "; $hourly_html .= "
    • $display_quarter $sched_busy{\"$hour:$quarter:$ampm\"}
    • "; $was_busy = 0; $was_available = 1; }else{ if($was_busy == 1){ $hourly_html .= "
    • $display_quarter $sched_busy{\"$hour:$quarter:$ampm\"}
    • "; }else{ $hourly_html .= "
    • $display_quarter $sched_busy{\"$hour:$quarter:$ampm\"}
    • "; } $was_busy = 1; $was_available = 0; } }else{ if($was_busy == 1){ $hourly_html .= "
    • $display_quarter
    • "; $was_busy = 0; $was_available = 0; }else{ $hourly_html .= "
    • $display_quarter
    • "; $was_available = 0; } } $quarter_count++; } $return_hash{$date}{$time} = $hourly_html; $html .= "
\n"; return %return_hash; } 1;