load($row); $offices[$tmpOffice->getOfficeId()] = $tmpOffice; } $view = isset($_GET['v']) ? $_GET['v'] : 'calendar'; if ($view == "office") { $officeId = $_GET['o']; $office = isset($officeId) ? $offices[$officeId] : current($offices); $pgName = $office->getOfficeName() . " Schedule"; } if (isset($office) == false) { $mo = isset($_GET['m']) ? $_GET['m'] : date("n"); $y = isset($_GET['y']) ? $_GET['y'] : date("Y"); $pgName = date("F Y", mktime(0,0,0, $mo, 1, $y))." Schedule"; } ?> Education Schedule

Office View"; } else { echo "Calendar View"; echo " | Office View"; } ?>

"; echo count($spot); foreach(array_keys($spot) as $tmp){echo "
$tmp"; } unset($spot["13:45:00"]); echo " aft count: ".count($spot); foreach(array_keys($spot) as $tmp){echo "
$tmp"; } $dateTS = strtotime("2011-03-30 09:00:00"); for ($i = 0; $i <= 3; $i++) { echo "
"; echo date("H:i:s", $dateTS); $dateTS = strtotime("+30 minutes", $dateTS); } echo "

"; **/ ?>
'; /* table headings */ $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $calendar.= ''.implode('',$headings).''; /* days and weeks vars now ... */ $running_day = date('w',mktime(0,0,0,$month,1,$year)); $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); $days_in_this_week = 1; $day_counter = 0; $dates_array = array(); /* row for week one */ $calendar.= ''; /* print "blank" days until the first of the current week */ for($x = 0; $x < $running_day; $x++): $calendar.= ' '; $days_in_this_week++; endfor; /* keep going with days.... */ for($list_day = 1; $list_day <= $days_in_month; $list_day++): $calendar.= ''; /* add in the day number */ $calendar.= '
'.$list_day.'
'; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ if ($running_day == 0 || $running_day == 6) { $calendar.= str_repeat('

 

',3); } else { $displayDate = date("Y-m-d", mktime(0,0,0,$month,$list_day,$year)); $schedule = isset($scheduleDates) ? $scheduleDates[$displayDate] : NULL; //$calendar.= str_repeat('

',2); //$calendar .= "View Schedule"; if (isset($schedule)) { $calendar .= "

"; $startTimeRaw = explode(":", $schedule->getStartTime()); $startTime = date("g:i", mktime($startTimeRaw[0],$startTimeRaw[1],0,$m,$list_day,$y)); $endTimeRaw = explode(":", $schedule->getEndTime()); $endTime = date("g:i", mktime($endTimeRaw[0],$endTimeRaw[1],0,$m,$list_day,$y)); $office = $offices[$schedule->getOfficeId()]; $calendar .= htmlspecialchars($office->getOfficeName()); $calendar .= "
"; $calendar .= $startTime."-".$endTime; $calendar .= "

"; $calendar .= "

Make Appointment

"; } else { $calendar .= "

 

"; $calendar .= "

 

"; $calendar .= "

 

"; } } $calendar.= ''; if($running_day == 6): $calendar.= ''; if(($day_counter+1) != $days_in_month): $calendar.= ''; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; /* finish the rest of the days in the week */ if($days_in_this_week < 8 && $running_day != 0): for($x = 1; $x <= (8 - $days_in_this_week); $x++): $calendar.= ' '; endfor; /* final row */ $calendar.= ''; endif; /* end the table */ $calendar.= ''; /* all done, return result */ return $calendar; } class UserSchedule { var $uscId; var $adminId; var $uscDate; var $officeId; var $startTime; var $endTime; function setUscId($tmp) { $this->uscId = $tmp; } function setAdminId($tmp) { $this->adminId = $tmp; } function setUscDate($tmp) { $this->uscDate = $tmp; } function setOfficeId($tmp) { $this->officeId = $tmp; } function setStartTime($tmp) { $this->startTime = $tmp; } function setEndTime($tmp) { $this->endTime = $tmp; } function getUscId() { return $this->uscId; } function getAdminId() { return $this->adminId; } function getUscDate() { return $this->uscDate; } function getOfficeId() { return $this->officeId; } function getStartTime() { return $this->startTime; } function getEndTime() { return $this->endTime; } function load($row) { $this->setUscId(stripslashes($row["UscId"])); $this->setAdminId(stripslashes($row["AdminId"])); $this->setUscDate(stripslashes($row["UscDate"])); $this->setOfficeId(stripslashes($row["OfficeId"])); $this->setStartTime(stripslashes($row["StartTime"])); $this->setEndTime(stripslashes($row["EndTime"])); } function getInstances($m = NULL, $y = NULL) { $q = "Select * from UserSchedule"; $r = mysql_query($q); $num_results = mysql_num_rows($r); if ($num_results > 0) { for ($i = 0; $i < $num_results; $i++) { $schedule = new UserSchedule(); $schedule->load(mysql_fetch_array($r)); $scheduleDates[$schedule->getUscDate()] = $schedule; } } return $scheduleDates; } } class CbhOffice { var $officeId; var $officeName; var $street1; var $street2; var $city; var $state; var $zip; var $phone; var $fax; var $latitude; var $longitude; var $trendId; var $lvarId; var $gsmlsId; var $urlname; function setOfficeId($newOfficeId) { $this->officeId = $newOfficeId; } function setOfficeName($newOfficeName) { $this->officeName = $newOfficeName; } function setStreet1($newStreet1) { $this->street1 = $newStreet1; } function setStreet2($newStreet2) { $this->street2 = $newStreet2; } function setCity($newCity) { $this->city = $newCity; } function setState($newState) { $this->state = $newState; } function setZip($newZip) { $this->zip = $newZip; } function setPhone($newPhone) { $this->phone = $newPhone; } function setFax($newFax) { $this->fax = $newFax; } function setLatitude($newLatitude) { $this->latitude = $newLatitude; } function setLongitude($newLongitude) { $this->longitude = $newLongitude; } function setTrendId($tmp) { $this->trendId = $tmp; } function setLVARId($tmp) { $this->lvarId = $tmp; } function setGSMLSId($tmp) { $this->gsmlsId = $tmp; } function setUrlname($tmp) { $this->urlname = $tmp; } function getOfficeId() { return $this->officeId; } function getOfficeName() { return $this->officeName; } function getStreet1() { return $this->street1; } function getStreet2() { return $this->street2; } function getCity() { return $this->city; } function getState() { return $this->state; } function getZip() { return $this->zip; } function getStreetStr() { $tmp = $this->street1; $s2 = $this->street2; if ($s2 && strlen($s2) > 0) { $tmp .= "
".$s2; } return $tmp; } function getCityStateZip() { $c = $this->city; $s = $this->state; $z = $this->zip; if ($c && strlen($c) > 0) { $csz = $c.", "; } if ($s && strlen($s) > 0) { $csz .= $s." "; } if ($z && strlen($z) > 0) { $csz .= $z; } return $csz; } function getAddressStr() { $tmp = $this->getStreetStr(); $csz = $this->getCityStateZip(); if ($csz && strlen($csz) > 0) { $tmp .= "
".$csz; } return $tmp; } function getPhone() { return $this->phone; } function getFax() { return $this->fax; } function getLatitude() { return $this->latitude; } function getLongitude() { return $this->longitude; } function getTrendId() { return $this->trendId; } function getLVARId() { return $this->lvarId; } function getGSMLSId() { return $this->gsmlsId; } function getUrlname() { return $this->urlname; } function load($row) { $this->setOfficeId(stripslashes($row["CBHOFFICE_ID"])); $this->setOfficeName(stripslashes($row["CBHOFFICE_NAME"])); $this->setStreet1(stripslashes($row["CBHOFFICE_STREET_1"])); $this->setStreet2(stripslashes($row["CBHOFFICE_STREET_2"])); $this->setCity(stripslashes($row["CBHOFFICE_CITY"])); $this->setState(stripslashes($row["CBHOFFICE_STATE"])); $this->setZip(stripslashes($row["CBHOFFICE_POSTAL"])); $this->setPhone(stripslashes($row["CBHOFFICE_PHONE"])); $this->setFax(stripslashes($row["CBHOFFICE_FAX"])); $this->setLatitude(stripslashes($row["CBHOFFICE_LATITUDE"])); $this->setLongitude(stripslashes($row["CBHOFFICE_LONGITUDE"])); $this->setTrendId(stripslashes($row["CBHOFFICE_TREND_ID"])); $this->setLVARId(stripslashes($row["CBHOFFICE_LVAR_ID"])); $this->setGSMLSId(stripslashes($row["CBHOFFICE_GSMLS_ID"])); $this->setUrlname(stripslashes($row["CBHOFFICE_URLNAME"])); return $this; } function getInstances() { $query = "Select * from CBH_OFFICE ORDER BY CBHOFFICE_NAME"; $result = mysql_query($query); $num_offices = mysql_num_rows($result); for ($i=0; $i<$num_offices; $i++) { $row = mysql_fetch_array($result); $tmpOffice = new CbhOffice(); $tmpOffice = $tmpOffice -> load($row); $offices[$i] = $tmpOffice; } return $offices; } } ?>