. */ /** * Note to anyone feeling the need to edit this file... * You MUST declare $db as global inside your functions in order access MySQL from here. */ /** * SelectDate($date) * Function for outputing an html form for selecting a month day and year * @param date - formatted date string yyyy-mm-dd (optional) */ function SelectDate($date = NULL){ //function for adding to the db in sql 'datetime' format //$date = date("Y-m-d h:i:s", mktime(8, 30, 0, 10, 26, 2009)); //$date = "2009-11-2"; //echo $date."
"; //function for parsing our date format into an array //echo "
";
	$date_arr = date_parse($date); //returns an associative array $array['year']
	//print_r($date_arr);
	//echo "
"; //echo $date_arr['year']." ".$date_arr['month']." ".$date_arr['day']."
";; //List Months echo '"; //List Days echo '"; //List Years [CurYear, CurYear+5] echo '"; } function ListEvents($date){ global $db; ?>

Events for:

Add New Event
"; $result = $db->Query("SELECT * FROM bayonet_events WHERE `date` = '$date' ORDER BY `time`"); while(($row = $db->Fetch($result))!=false) { $tmp = true; $datetime = date_create($date.' '.$row['time']); $time = date_format($datetime, 'g:ia'); //gets time in hour:minutes am|pm ?>      Edit  |  Delete


There are no events posted for this day."; echo ""; } /** * PrintCalendar() - prints the calendar with events */ function PrintCalendar(){ $date = time(); date_default_timezone_set("America/New_York"); //EASTERN TIME ZONE //GET values for month and year $month = ""; $year = ""; //$month = $_GET['month']; //$year = $_GET['year']; $useCurDate = true; //check to makes sure month and year are in the desired ranges if(!empty($month) && !empty($year) && $month > 0 && $month < 13 && $year > 1990){ $useCurDate = false; } //check to see if the get variables are for todays month if($month == date('n', $date) && $year == date('Y', $date)){ $useCurDate = true; } //use current date unless GET values are set if($useCurDate) { $day = date('d', $date); $today = date('j', $date); $month = date('m', $date); $monthNum = date('n', $date); $year = date('Y', $date); } else { $monthNum = $month; //if GET values are equal to curdate, set $today if($year == date('Y', $date) && $monthNum == date('n', $date)) $today = date('j', $date); else $today = 0; } /* Accounts for the last couple days from the previous months */ $first_day = mktime(0,0,0,$monthNum, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } /* calculates the days in the current month */ $days_in_month = cal_days_in_month(0, $monthNum, $year); //makes sure that previous year is not year 0 if($monthNum == 1){ $previous_month = 12; $previous_year = $year-1; }else{ $previous_month = $monthNum-1; $previous_year = $year; } //makes sure the next year is not year 13 if($monthNum == 12){ $next_month = 1; $next_year = $year+1; }else{ $next_month = $monthNum+1; $next_year = $year; } ?>
0){ $blank = $blank-1; $days_before = $days_monthbefore-$blank; echo ''; //'.$days_before.''; $day_count++; } //loop printing each day of the CURRENT month ONLY while($day_num <= $days_in_month){ if($day_count==1 || $day_count==7){ echo ''; $day_num++; $day_count++; if($day_count > 7){ echo ''; $day_count = 1; } } $days_after = 1; //loop for printing the days for the next month while($day_count > 1 && $day_count <=7){ echo ''; //'.$days_after.''; $days_after++; $day_count++; } ?>
    
SunMonTueWed ThuFriSat
'.$days_before.''; //weekends }else{ echo ''; //weekdays } $sqlDate = $year.'-'.$monthNum.'-'.$day_num; //old way NOT unix //checks to see if the current day has events $isEvent=false; global $db; $result = $db->Query("SELECT title,color FROM `bayonet_events` WHERE `date` = '$sqlDate' LIMIT 1"); while(($row = $db->Fetch($result))!=false) { $isEvent = true; } if($day_num == $today && $isEvent==true){ echo '
'.$day_num.'
'; }else if($day_num == $today && $isEvent==false){ echo '
'.$day_num.'
'; }else if($day_num != $today && $isEvent==true){ echo '
'; echo $day_num; echo '
'; }else{ echo $day_num; } echo '
'.$days_after.'