include_once ("includes/dbConnNew.php");
if($_REQUEST['procDate'] > " "){
list($y,$m,$d) = explode("-", $_REQUEST['procDate']);
$currProcDate = $_REQUEST['procDate'];
$displayMonth = date("F", mktime(0, 0, 0, $m, $d, $y));
$displayYear = date("Y", mktime(0, 0, 0, $m, $d, $y));
}else{
$currProcDate = date('Y-m-d');
$displayMonth = date("F");
$displayYear = date("Y");
}
//see if a cookie exists wit username and password
if( !$_SESSION['loggedIn'] ){
if ( ( $_COOKIE['cookieEmail'] > " ") && ( $_COOKIE['cookiePassword'] > " ") ){
header("location: signInToFridge.php");
exit();
}
}
include_once ("includes/loggedOnFridge.php");
function getPrevMonth($dateVar){
list($currentProcessingYear,$currentProcessingMonth,$currentProcessingDay) = explode("-", $dateVar);
if($currentProcessingMonth > "01"){
$prevProcessingMonth = $currentProcessingMonth - 1;
if($prevProcessingMonth < 10){ $prevProcessingMonth = "0" . $prevProcessingMonth;}
$prevProcessingYear = $currentProcessingYear;
$prevProcessingDay = $currentProcessingDay;
}else{
$prevProcessingMonth = "12";
$prevProcessingYear = $currentProcessingYear - 1;
$prevProcessingDay = $currentProcessingDay;
}
$prevProcessingDate = $prevProcessingYear . "-" . $prevProcessingMonth . "-" . $prevProcessingDay;
return $prevProcessingDate;
}
function getNextMonth($dateVar){
list($currentProcessingYear,$currentProcessingMonth,$currentProcessingDay) = explode("-", $dateVar);
if($currentProcessingMonth < "12"){
$nextProcessingMonth = $currentProcessingMonth + 1;
if($nextProcessingMonth < 10){ $nextProcessingMonth = "0" . $nextProcessingMonth;}
$nextProcessingYear = $currentProcessingYear;
$nextProcessingDay = $currentProcessingDay;
}else{
$nextProcessingMonth = "01";
$nextProcessingYear = $currentProcessingYear + 1;
$nextProcessingDay = "01";;
}
$nextProcessingDate = $nextProcessingYear . "-" . $nextProcessingMonth . "-" . $nextProcessingDay;
return $nextProcessingDate ;
}
?>
" "){
if($lastm == 0){
$lasty = $lasty -1 ;
$lastm = 12 ;
}
if($lastm == 13){
$lasty = $lasty +1 ;
$lastm = 1 ;
}
$thismonth = date("m",mktime(0, 0, 0, $lastm, 1, $lasty));
$thisyear = date("Y",mktime(0, 0, 0, $thismonth, 1,$lasty));
} else {
$date = date("Y-m-d") ;
$thisday = date("d",mktime((date("h")+3), 0, 0, date("m"), date("d"), date("Y")));
//$thisday = date('d');
$thismonth = date('m');
$thisyear = date('Y');
}
$lastDay = strftime("%d", mktime(0, 0, 0, ($thismonth + 1), 0, $thisyear));
$day=date("d", mktime(0, 0, 0, 04, $lastDay, 2008));
$firstDayWeek=date("D", mktime(0, 0, 0, $thismonth, 01, $thisyear));
$lastDayWeek=date("D", mktime(0, 0, 0, $thismonth, $lastDay, $thisyear));
$toMonth =date("F",mktime(0, 0, 0, $thismonth, 1, $thisyear));
$shoMonth=date("M",mktime(0, 0, 0, $thismonth, 1, $thisyear));
$today = $thisday ;
if($today == 01) {$today="1";}
if($today == 02) {$today="2";}
if($today == 03) {$today="3";}
if($today == 04) {$today="4";}
if($today == 05) {$today="5";}
if($today == 06) {$today="6";}
if($today == 07) {$today="7";}
if($today == 08) {$today="8";}
if($today == 09) {$today="9";}
$searchDate = date("Y-m-d");
$sqlTasks = "SELECT *, concat(t.ID,'_todo') AS id ,
t.Title AS Event_Name,
t.Todo_Notes AS Description,
t.Due_Date AS Event_date,
t.Completed AS Completed,
t.Folder_Ind,
t.Repeat_Ind,
folder_id AS todofolderid
FROM todo_list AS t where (User_ID = '$_SESSION[sessionUserID]' or Assign_To = '$_SESSION[sessionUserID]') and (Due_Date > '0000-00-00') and (t.deleted = 0) order by Start_Time asc";
$resultTasks = mysql_query($sqlTasks) or die(mysql_error());
$Todo_array = array();
while($Events=mysql_fetch_array($resultTasks)){
$Events["Event_Date"] = $Events[Event_date];
$editAbility = "yes";
if($Events[Source_Event] > "0"){
$editAbility = "no";
}
if($Events[Start_Time] > "00"){
$startTime = date("g:ia",mktime($Events[Start_Time],$Events[Start_Minute],0,1,5,2009));
} else {
$startTime = "";
}
if($Events[End_Time] > " "){
$endTime = date("g:ia",mktime($Events[End_Time],$Events[End_Minute],0,1,5,2009));
} else {
$endTime = " ";
}
//now figure out if this even should be shown on this date
$End_Date = $Events[End_Date];
if ( ($Events[Repeat_Ind] >= 1 && $Events[Repeat_Ind] <= 7 ) && ($Events[End_Date] == "0000-00-00") ) {
$End_Date = "2030-01-01";
}
// Loop for the Month
for($i=0;$i<$lastDay;$i++){
// Setting Flag
$showIt = "n";
$D[$i] = date("d",mktime(0,0,0,$thismonth, $i+1, $thisyear));
$eventDate = $thisyear."-".$thismonth."-".$D[$i] ;
$Month = $eventDate;
$searchDate = $Month;
switch ($Events[Repeat_Ind]) {
// daily
case "1":
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate)){
$showIt = "y";
}
break;
// weekdays
case "2":
$weekdays = array(1,2,3,4,5);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays) ) || strtotime($Events[Event_Date]) == strtotime($searchDate) ){
$showIt = "y";
}
break;
// Weekends
case "3":
$weekdays = array(6,7);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays)) ){
$showIt = "y";
}
break;
//Weekly
case "4":
$dayOfWeek =date("N",strtotime($searchDate));
$taskDay =date("N",strtotime($Events[Event_Date]));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $taskDay == $dayOfWeek){
$showIt = "y";
}
break;
//Monthly
case "5":
$dayOfMonth =date("j",strtotime($searchDate));
$taskDay =date("j",strtotime($Events[Event_Date]));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $taskDay == $dayOfMonth){
$showIt = "y";
}
break;
//Quarterly
case "6":
$dayOfMonth = strtotime($searchDate) ;
$orgDate = strtotime($Events[Event_Date]) ;
list($taskYear,$taskMonth,$taskDay) = explode("-", $Events[Event_Date]);
$numMonth = floor(($dayOfMonth-$orgDate)/2628000)+1 ;
if($numMonth%3 == "0"){
$nextQ = mktime(0,0,0,($taskMonth+$numMonth),$taskDay,$taskYear) ;
}
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $nextQ == $dayOfMonth){
$showIt = "y";
}
break;
// Yearly
case "7":
$dayOfYear = strtotime($searchDate) ;
$orgDate = strtotime($Events[Event_Date]) ;
$dm1 = substr($searchDate,5,5);
$dm2 = substr($Events[Event_Date],5,5);
list($taskYear,$taskMonth,$taskDay) = explode("-", $Events[Event_Date]);
$numYear = floor(($dayOfYear-$orgDate)/31536000) ;
$nextY = mktime(0,0,0,($taskMonth+1),$taskDay,($taskYear+$numYear)) ;
if( (strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $dm1 == $dm2) || ($Events[Event_Date] == $searchDate) ){
$showIt = "y";
}
break;
// Every Monday, Wednesday, and Friday
case "8":
$weekdays = array(1,3,5);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays) ) || strtotime($Events[Event_Date]) == strtotime($searchDate) ){
$showIt = "y";
}
break;
// Every Tuesday and Thursday
case "9":
$weekdays = array(2,4);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays) ) || strtotime($Events[Event_Date]) == strtotime($searchDate) ){
$showIt = "y";
}
break;
default:
if ($Events["Event_Date"] == $Month){$showIt = "y";}
break;
}
$Start_Time = date('g:i a',strtotime($Events["Event_Date"]." ".$Events["Start_Time"]));
//end of: figure out if this even should be shown on this date
// Assigning recurring Events in todo in Array
if($showIt == "y")
{
$day_disp = date("l",strtotime($searchDate));
$Todo_array[] = array("Event_Name"=>$Events["Event_Name"],
"day_disp"=>$day_disp,
"searchDate"=>date('M d,Y', strtotime($searchDate)),
"Start_Time"=>$startTime,
"ID"=>$Events["id"]."_".$Events["todofolderid"]."_".$Events["Folder_Ind"]."_".$Events["Completed"],
"inc"=>$inc);
$inc++;
}
}
}
################################## To do Array End ##################################
$Shared_array = array();
################################## Event Recurring Code ##################################
$Month = date('Y-m-d', $_REQUEST[tday] );
$sqlEvent = "select user_events.* from user_events where (user_events.deleted = 0) AND (User_ID = '$_SESSION[sessionUserID]' and Event_Date > '0000-00-00') order by Start_Time desc";
$resultEvent = mysql_query($sqlEvent) or die(mysql_error());
$Event_array = array();
while($Events=mysql_fetch_array($resultEvent)){
$editAbility = "yes";
if($Events[Source_Event] > "0"){
$editAbility = "no";
}
if($Events[Start_Time] > "00"){
$startTime = date("g:ia",mktime($Events[Start_Time],$Events[Start_Minute],0,1,5,2009));
} else {
$startTime = " ";
}
if($Events[End_Time] > "00"){
$endTime = date("g:ia",mktime($Events[End_Time],$Events[End_Minute],0,1,5,2009));
} else {
$endTime = " ";
}
//now figure out if this even should be shown on this date
//if ($Events[Event_Date] == $Month){$showIt = "y";}
$End_Date = $Events[End_Date];
if ( ($Events[Repeat_Ind] >= 1 && $Events[Repeat_Ind] <= 7 ) && ($Events[End_Date] == "0000-00-00") ) {
$End_Date = "2030-01-01";
}
for($i=0;$i<$lastDay;$i++){
$showIt = "n";
$D[$i] = date("d",mktime(0,0,0,$thismonth, $i+1, $thisyear));
$eventDate = $thisyear."-".$thismonth."-".$D[$i] ;
$Month = $eventDate;
$searchDate = $Month;
switch ($Events["Repeat_Ind"]) {
// daily
case "1":
if(strtotime($Events["Event_Date"]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate)){
$showIt = "y";
}
break;
// weekdays
case "2":
$weekdays = array(1,2,3,4,5);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays) ) || strtotime($Events[Event_Date]) == strtotime($searchDate) ){
$showIt = "y";
}
break;
// Weekends
case "3":
$weekdays = array(6,7);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays)) ){
$showIt = "y";
}
break;
//Weekly
case "4":
$dayOfWeek =date("N",strtotime($searchDate));
$taskDay =date("N",strtotime($Events[Event_Date]));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $taskDay == $dayOfWeek){
$showIt = "y";
}
break;
//Monthly
case "5":
$dayOfMonth =date("j",strtotime($searchDate));
$taskDay =date("j",strtotime($Events[Event_Date]));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $taskDay == $dayOfMonth){
$showIt = "y";
}
break;
//Quarterly
case "6":
$dayOfMonth = strtotime($searchDate) ;
$orgDate = strtotime($Events[Event_Date]) ;
list($taskYear,$taskMonth,$taskDay) = explode("-", $Events[Event_Date]);
$numMonth = floor(($dayOfMonth-$orgDate)/2628000)+1 ;
if($numMonth%3 == "0"){
$nextQ = mktime(0,0,0,($taskMonth+$numMonth),$taskDay,$taskYear) ;
}
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $nextQ == $dayOfMonth){
$showIt = "y";
}
break;
// Yearly
case "7":
$dayOfYear = strtotime($searchDate) ;
$orgDate = strtotime($Events[Event_Date]) ;
//
$dm1 = substr($searchDate,5,5);
$dm2 = substr($Events[Event_Date],5,5);
list($taskYear,$taskMonth,$taskDay) = explode("-", $Events[Event_Date]);
$numYear = floor(($dayOfYear-$orgDate)/31536000) ;
$nextY = mktime(0,0,0,($taskMonth+1),$taskDay,($taskYear+$numYear)) ;
if((strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && $dm1 == $dm2) || ($Events[Event_Date] == $searchDate) ){
$showIt = "y";
}
break;
// Every Monday, Wednesday, and Friday
case "8":
$weekdays = array(1,3,5);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays) ) || strtotime($Events[Event_Date]) == strtotime($searchDate) ){
$showIt = "y";
}
break;
// Every Tuesday and Thursday
case "9":
$weekdays = array(2,4);
$dayOfWeek =date("N",strtotime($searchDate));
if(strtotime($Events[Event_Date]) <= strtotime($searchDate) && strtotime($End_Date) >= strtotime($searchDate) && (in_array($dayOfWeek, $weekdays) ) || strtotime($Events[Event_Date]) == strtotime($searchDate) ){
$showIt = "y";
}
break;
default:
if ($Events["Event_Date"] == $Month){$showIt = "y";}
break;
}
$Start_Time = date('g:i a',strtotime($Events["Event_Date"]." ".$Events["Start_Time"]));
//end of: figure out if this even should be shown on this date
if($showIt == "y"){
$day_disp = date("l",strtotime($searchDate));
$Event_array[] = array("Event_Name"=>$Events["Event_Name"],
"day_disp"=>$day_disp,
"searchDate"=>date('M d,Y', strtotime($searchDate)),
"Start_Time"=>$startTime,
"ID"=>$Events["ID"],
"inc"=>$inc);
$inc++;
}
}
}
// Mergin Array of Event , To do
$Event_array = array_merge($Event_array,$Todo_array);
$arrEvent = array();
$arrAlready = array();
// Combining Events of Events, Todo AS DATE calender
if(count($Event_array)>0)
{
foreach($Event_array as $key=>$value) {
$MainSearchDate = date('M d,Y', strtotime($value['searchDate']));
foreach($Event_array as $k=>$v) {
$searchDate = date('M d,Y', strtotime($v['searchDate']));
if($MainSearchDate == $searchDate && !in_array($v['inc'],$arrAlready)) {
//$arrEvent[$MainSearchDate][] = $v;
$arrEvent[$MainSearchDate][] = $v;
$arrAlready[] = $v['inc'];
}
}
}
}
// Sort the First level of 2d Array
ksort($arrEvent);
$f=0;
foreach($arrEvent as $key => $value){
$arrNewEvent[$f] = $value;
$f++;
}
$colorNum = 1 ;
$color2Num = 1 ;
####################################
# code for pagination starts #
####################################
function loadVariable($Variable, $Default){
if(!empty($_GET[$Variable]))
return $_GET[$Variable];
elseif(!empty($_POST[$Variable]))
return $_POST[$Variable];
else
return $Default;
}
$page = loadVariable("page",1);
$numPerPage = loadVariable("numPerPage",31);
$pagecount = loadVariable("pagecount","");
if($pagecount>$page){
$pagecount = $page;
}else{
$pagecount = 0;
}
$iCount = count($arrNewEvent);
$totalPages = ceil($iCount/$numPerPage);
if($page > $totalPages){
$page = $totalPages;
}if($totalPages ==0){
$page = 1;
}
$start = ($page*$numPerPage)-$numPerPage;
$end = ($page)*$numPerPage;
#####################################
# code for pagination Ends #
#####################################
for($j=$start;$j<$iCount;$j++){
if($j < $end )
{
?>
= $arrNewEvent[$j][0]["searchDate"] ?> $dateLink = strtotime($arrNewEvent[$j][0]["searchDate"]) ?>
"0"){
$sqlName = "select users.* from users, todo_list where (todo_list.ID = '$todo_id') and (todo_list.deleted = 0) AND (todo_list.User_ID = users.ID) and (Due_Date > '0000-00-00') ";
$resultName = mysql_query($sqlName) or die(mysql_error());
if ($myrowName = mysql_fetch_array ($resultName)){
$displayName = $myrowName['First_Name'] . " " . substr($myrowName['Last_Name'],0,1) . ".";
}
}
//end of get author name
//get author name for cal
if($event_id > "0"){
$sqlName = "select users.* from users, user_events where (user_events.ID = '$event_id') and (user_events.deleted = 0) AND (user_events.User_ID = users.ID) and (Event_Date > '0000-00-00') ";
$resultName = mysql_query($sqlName) or die(mysql_error());
if ($myrowName = mysql_fetch_array ($resultName)){
$displayName = $myrowName['First_Name'] . " " . substr($myrowName['Last_Name'],0,1) . ".";
}
}
//end of get author name
?>
- if($arrNewEvent[$j][$i]["Start_Time"] > "00"){ ?>= $arrNewEvent[$j][$i]["Start_Time"]?> if($arrNewEvent[$j][$i]["End_Time"] > "00"){?> - =$arrNewEvent[$j][$i]["End_Time"]?> } }else {?>Time not specified } ?>
- \n");?>
Posted by = $displayName ?>
} ?>
} }?>