<?PHP
// $Id: index.php,v 1.1 2004/07/11 10:27:51 Farsus 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($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['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='"._CONFEVENT."'></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>"._DATEVENT."</B></TD>
	  <TD><B>"._SUB."</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='../images/edit.gif' BORDER=0 WIDTH=16 HEIGHT=19 ALT='"._VALID."'></A><A HREF='action.php?pa=Delete&id=".$row['id']."'><IMG SRC='../images/del.gif' BORDER=0 WIDTH=16 HEIGHT=19 ALT='"._DELEVENT."'></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='"._DELEVENT."'></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='../images/down.gif' ALT='"._CAL_SORT."'></a> "._DATEVENT." <a href='index.php?sort=e.stamp DESC'><IMG SRC='../images/up.gif' ALT='"._CAL_SORT."'></a></B></CENTER></TD>
	  <TD><CENTER><B>"._SUB."</B></CENTER></TD>
	  <TD><CENTER><B><a href='index.php?sort=k.title ASC'><IMG SRC='../images/down.gif' ALT='"._CAL_SORT."'></a> "._CAL_KAT." <a href='index.php?sort=k.title DESC'><IMG SRC='../images/up.gif' ALT='"._CAL_SORT."'></a></B></CENTER></TD>
	  <TD><CENTER><B><a href='index.php?sort=l.location ASC'><IMG SRC='../images/down.gif' ALT='"._CAL_SORT."'></a> "._CAL_LOCATION." <a href='index.php?sort=l.location DESC'><IMG SRC='../images/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='../images/edit.gif' BORDER=0 WIDTH=16 HEIGHT=19 ALT='"._CAL_MODIF."'></A></td></tr>";
  }
 echo    "</TABLE><BR><input type='submit' class='button' name='delete_messages' value='"._DELEVENT."' 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>"._CAL_LOCATION2."</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='../images/edit.gif' border='0' width='16' height='19' alt='"._CAL_MODIF."'></a>";
            echo "<a href='addlocation.php?op=dellocation&lid=".$new_loc->lid()."&ret=1'><img src='../images/del.gif' border='0' width='16' height='19' alt='"._DELEVENT."'></a>";
            echo "</center></td></tr>";
        }
        echo "</table>";
    }
CloseTable();
xoops_cp_footer();
?>

