Sabado = 6
$this -> daysofweek = array ("Dom ", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado");
$this -> workweekstarts = 0;
$this -> workweekends = 6;
$this -> workdaystarts = 8;
$this -> workdayends = 19;
$this -> weekDate = array();
}
function getUserCalendar($type,$date, $userId){
$calendarUser = array (
"20071008" => array(
"0900" => "Cafe da Manha",
"1100" => "Lanche da Manhã",
"1600" => "Almoco Executivo",
"1500" => "Cafe da Tarde"
),
"20071009" => array(),
"20071126" => array(
"0800" => "Cafe da Manha",
"1000" => "Lanche da Manhã",
"1200" => "Almoco Executivo",
"1530" => "Cafe da Tarde",
"1800" => "Hora de ir embora"
),
"20071011" => array(),
"20071012" => array(),
"20071013" => array(
"1000" => "Cafe da Manha",
"1400" => "Almoco Executivo",
"1700" => "Cafe da Tarde",
),
"20071014" => array()
);
if($type == 'week')
return $calendarUser;
elseif($type == 'day')
return $calendarUser[$date];
}
function getWorkDay($date){
$workday = '';
for($i = $this->workdaystarts; $i <= $this->workdayends; $i = $i + 0.5){
if($i == intval($i))
$workday.= "".($i < 10 ? "0" : "").intval($i)."00".($i < 10 ? "0" : "").intval($i).":00";
else
$workday.= "".($i < 10 ? "0" : "").intval($i)."30".($i < 10 ? "0" : "").intval($i).":30";
}
return $workday;
}
function getWorkWeek(){
$workweek = '';
for($i = $this->workweekstarts; $i <= $this->workweekends; $i++){
$workweek.= "".$this -> weekDate[$i]."".$this->daysofweek[$i]."";
}
return $workweek;
}
function getViewDay($params){
$userId = $params['userId'];
$date = $params['date'];
$calendarUser = $this->getUserCalendar('day',$date, $userId);
$return = "$date";
if($calendarUser) {
foreach($calendarUser as $time => $title) {
$return.= "$date$time$title";
}
}
return $return.$this->getWorkDay($date);
}
function getViewWeek($params){
$userId = $params['userId'];
$date = $params['date'];
$tstamp=mktime(0,0,0,substr($date,4,2),substr($date,6,2),substr($date,0,4));
$Tdate = getdate($tstamp);
$calendarUser = $this->getUserCalendar('week',$date, $userId);
$return = "$date";
for ($dayofweek = 0; $dayofweek < 7; $dayofweek++){
$offset = $Tdate['wday'] - $dayofweek;
$weekday = getdate($tstamp - ($offset*86400));
$this -> weekDate[$dayofweek] = $weekday['year'].($weekday['mon'] < 10 ? "0" : "" ).$weekday['mon'].($weekday['mday'] < 10 ? "0" : "" ).$weekday['mday'];
if($calendarUser[$this -> weekDate[$dayofweek]]) {
foreach($calendarUser[$this -> weekDate[$dayofweek]] as $time => $title) {
$return.= "".$this -> weekDate[$dayofweek]."$time$title";
}
}
}
return $return.$this->getWorkDay($date).$this->getWorkWeek($date);
}
function getViewMonth($params){
$userId = $params['userId'];
return '';
}
function getViewYear($params){
$userId = $params['userId'];
return '';
}
}
?>