<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.9 www.exoops.info 2006/03 
// $Id: displayh.php,v 1.8 2004/01/22 10:33:58 nobse Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Nobse, Bama
// Author Website : http://www.e-xoops.de, http://service.bama-webdesign.de
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include("header.php");
include(XOOPS_ROOT_PATH."/header.php");

if ($xoopsUser) {
	$useroffset = $xoopsUser->getVar("timezone_offset");
} else {
	$useroffset = $bcoosConfig['default_TZ'];
}

$usertimevent = (time() + (($useroffset - ($bcoosConfig['server_TZ'] - date('I'))) * 3600));

$heute = !empty($_POST['heute']) ? $_POST['heute'] : $_GET['heute'];

if ($heute == 0) {
	$usertimevent = (time() + (($useroffset - ($bcoosConfig['server_TZ'] - date('I'))) * 3600));
	$day = date("j", $usertimevent);
	$month = date("m", $usertimevent);
	$year = date("Y", $usertimevent);
	$lastday = date("j",strtotime("-1 day",$usertimevent));
	$nextday = date("j",strtotime("+1 day",$usertimevent));
	$currentday = $day;
	$currentmonth = $month;
	$currentyear = $year;
	define("_NAVPAGE","TODAY");
	}else{
	$usertimevent = (time() + (($useroffset - ($bcoosConfig['server_TZ'] - date('I'))) * 3600 + 86400));
	$day = date("j", $usertimevent);
	$month = date("m", $usertimevent);
	$year = date("Y", $usertimevent);
	$lastday = date("j",strtotime("-1 day",$usertimevent));
	$nextday = date("j",strtotime("+1 day",$usertimevent));
	$currentday = $day;
	$currentmonth = $month;
	$currentyear = $year;
	define("_NAVPAGE","TOMORROW");
	}
	
OpenTable();


include ("include/nav.php");

 		form_nav_top_day($lastday, $currentmonth, $currentyear, $nextday, $currentday);
    
       	$query = $db->query("SELECT * FROM ".$db->prefix("ecal")." WHERE (stamp >= \"$year-$month-$day 00:00:00\" AND stamp <= \"$year-$month-$day 23:59:59\") AND valid ='yes' ORDER BY stamp");
		$result=$db->getRowsNum($query);

		if (!$result ) {
			echo "<BR><CENTER><B>"._NOEVENTDAY."</B></CENTER><BR>";
		} else {

        while ($row = $db->fetchArray($query)){
						
			$nomuser = $row['username'];
 			$auteur = $db->query("SELECT uid FROM ".$db->prefix("users")." where uname='$nomuser'");
			list($uid) = $db->fetchRow($auteur);
			
			$kat = $db->query("SELECT title, cid FROM ".$db->prefix("ecal_cat")." where cid=".$row['cid']);
			$kategorie = $db->fetchArray($kat);
			
			$locat = $db->query("SELECT lid, location, email, url FROM ".$db->prefix("ecal_location")." where lid=".$row['locationid']);
			$location = $db->fetchArray($locat);
			
			$Calanddate = $row['stamp'];
			$Calanddate = strftime(_EVEDATESTRING,strtotime($Calanddate));
			$heurmin = strftime(_EVETIME,strtotime($Calanddate));
			$date = strftime(_EVEDATESHORT,strtotime($Calanddate));
			
			include ("include/displayform.php");

		}
	}

		echo "<table border='0' width='100%' cellpadding='2' cellspacing='0'><tr class='bg3'>";
        echo "<td align='left'>";
        form_last_day($lastday, $currentmonth, $currentyear);
        echo "</td>";
		if ($xoopsUser) {
			$group = $xoopsUser->groups();
    	}else{
			$group[] = 3;
		}
		$anno = explode("|", $anoevent);
		$is = array_intersect ($group, $anno);
		
		if (count($is) > 0) {
            echo "<td align='center'>";
            form_add_event($month, $year);
            echo "</td>";        
		} else {
            echo "<td>&nbsp;</td>";
		}
		echo "<td align='right'>";
        form_next_day($nextday, $currentmonth, $currentyear);
        echo "</td></tr></table>";	
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
?>