<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.7 www.exoops.info 2006/03 
// $Id: localleve.php,v 1.6 2004/02/13 19:51:04 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");

$lid = $_GET['lid'];

if($xoopsUser){
	$timezone = $xoopsUser->timezone();
	if(isset($timezone)){
		$useroffset = $xoopsUser->timezone();
	}else{
		$useroffset = $bcoosConfig['default_TZ'];
	}
}

$usertimevent = time() + ($useroffset*3600);
$currentday = date("j", $usertimevent);
$currentmonth = date("m", $usertimevent);
$currentyear = date("Y", $usertimevent);
$day = $currentday;
$month = $currentmonth;
$year = $currentyear;

$lastseconds = mktime(0,0,0,$month,$day,$year)-(24*60*60);
$lastday = date('j', $lastseconds);
$lastmonth = date('m', $lastseconds);
$lastyear = date('Y', $lastseconds);
$nextseconds = mktime(0,0,0,$month,$day,$year)+(24*60*60);
$nextday = date('j', $nextseconds);
$nextmonth = date('m', $nextseconds);
$nextyear = date('Y', $nextseconds);

$query = $db->query("SELECT * FROM ".$db->prefix("ecal")." WHERE stamp >= \"$currentyear-$currentmonth-$currentday 00:00:00\" AND locationid =$lid AND valid ='yes' ORDER BY stamp");

$kat1 = $db->query("SELECT location FROM ".$db->prefix("ecal_location")." where lid=$lid");
	list($loctitle) = $db->fetchRow($kat1);


OpenTable();
include ("include/nav.php");

echo "<table border='0' width='100%' class='bg3'><tr>";
	if ($lid) {
	    echo "<td align='center'><b>"._CAL_ALLLOCEVENT.$loctitle."</b></td></tr></table>";
	}else{
		echo "<td align='center'><b>$day ";
		echo getMonthName($month);
		echo " $year</b></td></tr></table>";
	}

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'>";
		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></tr></table";
		} else {
        echo "<td>&nbsp;</td></tr></table>";
		}
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
?>