<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
// $Id: index.php,v 1.8 2004/02/06 21:22:10 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("admin_header.php");
include("../cache/config.php");
include("../include/function.php");
    if (!defined("ecal_LOCATION_INCLUDED")) {include_once(XOOPS_ROOT_PATH."/modules/ecal/class/location.php");}
xoops_cp_header();
$sort = !empty($_GET['sort']) ? $_GET['sort']: "e.stamp ASC";
?>
	<script language='javascript'>
		<!--
		function CheckAll() {
		    for (var i=0;i<document.events.elements.length;i++) {
				var e = document.events.elements[i];
				if ((e.name != 'toutbox') && (e.type=='checkbox')) {
					e.checked = document.events.toutbox.checked;
				}
			}
		}
		function CheckCheckAll() {
			var TotalBoxes = 0;
			var TotalOn = 0;
			for (var i=0;i<document.events.elements.length;i++) {
				var e = document.events.elements[i];
				if ((e.name != 'toutbox') && (e.type=='checkbox')) {
					TotalBoxes++;
					if (e.checked) {
						TotalOn++;
					}
				}
			}
			if (TotalBoxes==TotalOn) {
				document.events.toutbox.checked=true;
			} else {
				document.events.toutbox.checked=false;
			}
		}
	//-->
	</script>
<?
echo "<script language='javascript'>\nfunction EC(EC) { var MainWindow = window.open (EC, '_blank','width=380,height=240,toolbar=no,location=no,menubar=no,scrollbars=yes,resizeable=yes,status=no');}\n</script>";
OpenTable();
echo "<B>"._EVENTADMIN."</B><p>";
echo "<table cellpadding='2' cellspacing='0' align='center'><tr>";
echo "<td><form method='post' name='addevent' action='../addevent.php'><input type='submit' class='button' value='"._ADDITEM."'></form></td>";
echo "<td><form method='post' name='pref' action='./pref.php'><input type='submit' class='button' value='"._CONFIGURATION."'></form></td>";
echo "<td><form method='post' name='addcat' action='./addcat.php'><input type='submit' class='button' value='"._ADDCAT."'></form></td>";
echo "<td><form method='post' name='addlocation' action='./addlocation.php'><input type='submit' class='button' value='"._CAL_INDEXLOCATION."'></form></td>";
echo "</tr></table>";
echo "</p><P>";
$query = mysql_query("SELECT *  FROM ".$db->prefix("ecal")." WHERE valid = 'no' ORDER BY stamp ASC");
$event=mysql_num_rows($query);
if(!$event) {
  echo ""._NOEVENTSWAIT."<P>";
} else {  
  echo ""._THEREIS." <FONT COLOR='#FF0000'>$event</FONT> "._EVENTSWAIT."<p>";
  echo "<TABLE BORDER='0' CELLPADDING='4' CELLSPACING='1' class='bg2'>
    <TR>
      <TD WIDTH=20 class='bg2'><CENTER><B>"._NUM."</B></CENTER></TD>
      <TD><B>"._USER."</B></TD>
	  <TD><B>"._DATE."</B></TD>
	  <TD><B>"._SUBJECT."</B></TD>
      <TD><CENTER><B>"._OPTIONEV."</B></CENTER></TD>
    </TR>";
 while ($row = mysql_fetch_array($query)){
 		$Calanddate = $row['stamp'];
		$Calanddate = strftime(_EVEDATESTRING,strtotime($Calanddate));
	 echo "<tr class='bg1'><td><CENTER>".$row['id']."</CENTER></td><td>".$row['username']."</td><td>$Calanddate</td><td><A HREF='javascript:EC('../display-event-admin.php?id=".$row['id']."')'>".$row['subject']."</A></td><td align=center><A HREF='modifevent.php?id=".$row['id']."&ok=val'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."edit.gif' BORDER=0 WIDTH=16 HEIGHT=19 ALT='"._VALID."'></A><A HREF='action.php?pa=Delete&id=".$row['id']."'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."delete.gif' BORDER=0 WIDTH=16 HEIGHT=19 ALT='"._DELETE."'></A></td></tr>";
  }
 echo    "</TABLE><P><BR>";
}
echo "<P><BR>";
//echo $locat_yn;
if ($locat_yn == 1) {
	$query = mysql_query("SELECT k.title, l.location, e.* FROM ".$db->prefix("ecal")." e INNER JOIN ".$db->prefix("ecal_cat")." k ON k.cid=e.cid INNER JOIN ".$db->prefix("ecal_location")." l ON l.lid=e.locationid WHERE e.valid = 'yes' and e.privat = 0 ORDER BY ".$sort."");
}else{
	$query = mysql_query("SELECT k.title, e.* FROM ".$db->prefix("ecal")." e INNER JOIN ".$db->prefix("ecal_cat")." k ON k.cid=e.cid  WHERE e.valid = 'yes' and e.privat = 0 ORDER BY ".$sort."");
}
$event=mysql_num_rows($query);
if(!$event) {
  echo ""._NOEVENTS."<P>";
} else {  
  echo ""._THEREIS." <FONT COLOR='#FF0000'>$event</FONT> "._EVENTS."<p>";
//Del Events 
	$day = date('d');
	$month = date('m');
	$year = date('Y'); 
  echo "<form name='eventsdel' method='post' action='action.php'>";
  echo "<table>";
  echo "<tr><td>"._CAL_DELEVENT."</td>";
  echo "<td><select class='select' size='1' name='day'>";
  buildDaySelect($day);
  echo "</select><select class='select' size='1' name='month'>";
  buildMonthSelect($month);
  echo "</select><select class='select' size='1' name='year'>";
  buildYearSelect($year);
  echo "</td></tr>";		
  echo "<input type='hidden' name='pa' value='eventdel'>";
  echo "<tr><td><input type='submit' class='button' name='delete_messages' value='"._DELETE."'></td><td></td></tr>";
  echo "</table>";
  echo "</form>";
//**************  
  echo "<form name='events' method='post' action='action.php'><INPUT TYPE='hidden' NAME='pa' VALUE='DeleteS'>";
  echo "<TABLE BORDER='0' CELLPADDING='4' CELLSPACING='1' class='bg2'>
    <TR>
      <TD class='bg2'><CENTER><input name='toutbox' onclick='CheckAll();' type='checkbox' value='Check tout' /></CENTER></TD>
      <TD WIDTH='20' class='bg2'><CENTER><B>"._NUM."</B></CENTER></TD>
      <TD><CENTER><B>"._USER."</B></CENTER></TD>
	  <TD><CENTER><B><a href='index.php?sort=e.stamp ASC'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif' ALT='"._CAL_SORT."'></a> "._DATEVENT." <a href='index.php?sort=e.stamp DESC'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif' ALT='"._CAL_SORT."'></a></B></CENTER></TD>
	  <TD><CENTER><B>"._SUBJECT."</B></CENTER></TD>
	  <TD><CENTER><B><a href='index.php?sort=k.title ASC'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif' ALT='"._CAL_SORT."'></a> "._CATEGORY.':'." <a href='index.php?sort=k.title DESC'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif' ALT='"._CAL_SORT."'></a></B></CENTER></TD>
	  <TD><CENTER><B><a href='index.php?sort=l.location ASC'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif' ALT='"._CAL_SORT."'></a> "._CAL_LOCATION." <a href='index.php?sort=l.location DESC'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif' ALT='"._CAL_SORT."'></a></B></CENTER></TD>
	  <TD>&nbsp;</TD>
    </TR>";
 while ($row = mysql_fetch_array($query)){
  		$Calanddate = $row['stamp'];
		$Calanddate = strftime(_EVEDATESTRING,strtotime($Calanddate));
 echo "<tr class='bg1'><td><center><input type='checkbox' onclick='CheckCheckAll();' name='id[]' value='".$row['id']."' /></center></td>";
 echo "<td><CENTER>".$row['id']."</CENTER></td>";
 echo "<td>".$row['username']."</td>";
 echo "<td>$Calanddate</td>";
 echo "<td>".$row['subject']."</td>";
 echo "<td>".$row['title']."</td>";
 echo "<td>".$row['location']."</td>";
 echo "<td><A HREF='modifevent.php?id=".$row['id']."&ok=mod'><IMG SRC='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."edit.gif' BORDER=0 WIDTH=16 HEIGHT=19 ALT='"._MODIFY."'></A></td></tr>";
  }
 echo    "</TABLE><BR><input type='submit' class='button' name='delete_messages' value='"._DELETE."' border='0' /></form><P><BR>";
}
//bama
    $count_new_loc = CalLocation::countAllLocations(array("valid = 0"));
    if ($count_new_loc > 0){  
        echo _THEREIS." <font color='#FF0000'>".$count_new_loc."</font> "._CAL_NEWLOCATION."<p>";
        echo "<table border='0' cellpadding='4' cellspacing='1' class='bg2'>";
        echo "<tr><td width='20' class='bg2' algin='center'><b>"._NUM."</b></td>";
        echo "<td><b>"._LOCATION."</b></td>";
        echo "<td><b>"._CAL_URL2."</b></td>";
        echo "<td><b>"._CAL_ORT2."</b></td>";
        echo "<td algin='center'><b>"._OPTIONEV."</b></td></tr>";
        $new_location = CalLocation::getAllLocations(array("valid = 0"), true);
        foreach ( $new_location as $new_loc ) {
            echo "<tr class='bg1'><td algin='center'>".$new_loc->lid()."</td>";
            echo "<td>".$new_loc->location()."</td>";
            echo "<td>".$new_loc->url()."</td>";
            echo "<td>".$new_loc->ort()."</td>";
            echo "<td><center>";
            echo "<a href='addlocation.php?op=editlocation&lid=".$new_loc->lid()."&ret=1'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."edit.gif' border='0' width='16' height='19' alt='"._MODIFY."'></a>";
            echo "<a href='addlocation.php?op=dellocation&lid=".$new_loc->lid()."&ret=1'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."delete.gif' border='0' width='16' height='19' alt='"._DELETE."'></a>";
            echo "</center></td></tr>";
        }
        echo "</table>";
    }
CloseTable();
xoops_cp_footer();
?>
