<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.2 www.exoops.info 2006/03 
// $Id: modifevent.php,v 1.13 2004/02/13 19:51:06 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(XOOPS_ROOT_PATH."/modules/ecal/include/function.php");
include_once(XOOPS_ROOT_PATH."/class/xoopsform/formdhtmltextarea.php");
include(XOOPS_ROOT_PATH."/class/xoopsform/formselect.php");
include_once(XOOPS_ROOT_PATH."/class/xoopstree.php");
include_once("../cache/config.php");

xoops_cp_header();

$mytree = new XoopsTree($db->prefix('ecal_cat'), "cid", "pid");

global $xoopsUser, $db, $myts;

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


OpenTable();

if (!$id) {
echo "<p>"._ERRORMSG1."";
break;
}

if ($ok == mod) {
echo "<B>"._MSG3."</B>";
} else {
echo "<B>"._MSG4."</B>";
}

$query = $db->query("SELECT *, RIGHT(stamp, 8) AS thetime FROM ".$db->prefix("ecal")." WHERE id = '$id'");
$row = $db->fetchArray($query);

$kat = $db->query("SELECT title, cid FROM ".$db->prefix("ecal_cat")." where cid=".$row['cid']);
list($title, $cid) = $db->fetchRow($kat);

$subject = $myts->makeTboxData4Edit($row['subject']);
$description = $myts->makeTboxData4Edit($row['description']);

$heure = substr($row['thetime'],0,2);
$minute = substr($row['thetime'],3,2);
$heureend = substr($row['eventend'],0,2);
$minuteend = substr($row['eventend'],3,2);
$day = substr($row['stamp'],8,2);
$month = substr($row['stamp'],5,2);
$year = substr($row['stamp'],0,4);

echo "<form method='post' action='action.php'><input type='hidden' name='id' value='".$row['id']."'><table><tr>";
echo "<td><b>"._USER."</td>";
echo "<td>".$row['username']." <input type='hidden' name='username' value='".$row['username']."'></td></tr>";

echo "<tr><td><b>"._CATEGORY.':'."</b></td><td>";
echo $mytree->makeMySelBox("title", "title", $cid, 1, "cid");
echo "</td></tr>";

if (intval($locat_yn) == 1){
$query1 = $db->query("SELECT lid, location FROM ".$db->prefix("ecal_location")." ORDER BY location");
echo "<tr><td><b>"._CAL_LOCATION."</b></td><td>";
	echo "<select class='select' name='locationid'>";
		 while ($location = $db->fetchArray($query1)){
			 if ($location['lid'] == $row['locationid']) {
			     $sel = "selected";
		 	}else{
				$sel = "";
			}
			 echo "<option value='".$location['lid']."' $sel>".$location['location']."</option>";
		 }
echo "</select>";
echo "&nbsp;&nbsp;";
echo "<a href='addlocation.php'><img src='".XOOPS_URL."/modules/ecal/language/".$bcoosConfig['language']."/images/icon_new_loc.gif''></a>";
echo "</td></tr>";
}

echo "<tr><td><b>"._CAL_PRIVAT1."</b></td><td>";
$privat_select = new XoopsFormSelect(_CAL_PRIVAT, "privat", $row['privat']);
$privat_select->addOptionArray(array(0 =>_CAL_OFFEN,1 =>_CAL_PRIVAT));
echo $privat_select->render();
echo "</td></tr>";

echo "<tr><td><b>"._D."</td><td><select class='select' name='day' size='1'>";
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 "</select></tr>";

echo "<tr><td><b>"._CAL_BEGINN."</td><td><select class='select' name='heure' size='1'>";
buildHourSelect($heure);
echo "</select><select class='select' size='1' name='minute'>";
buildMinSelect($minute);
echo "</select></td></tr>";

echo "<tr><td><b>"._CAL_END."</td><td><select class='select' name='heureend' size='1'>";
buildHourSelect($heureend);
echo "</select><select class='select' size='1' name='minuteend'>";
buildMinSelect($minuteend);
echo "</select></td></tr>";

$chk1 = ''; $chk0 = '';
$row['high'] == 1 ? $chk1 = " checked='checked'" : $chk0 = " checked='checked'";
echo "<tr><td><b>"._CAL_HIGH."</td><td>";
echo "<input type='radio' class='radio' name='high' value='1' '$chk1' />"._YES."";
echo "<input type='radio' class='radio' name='high' value='0' '$chk0' />"._NO."</td></tr>";

echo "<tr><td><b>"._SUBJECT."</td><td><input class='text' type='text' name='subject' value='".$subject."' size='40'></td></tr>";

echo "<tr><td><b>"._DESCRIPTION."</b></td><td>";
		$desc = new XoopsFormDhtmlTextArea('', 'description1', $description, 10, 50);
		echo $desc->render();
		echo "</td></tr>";
		
echo "<tr><td><b>"._CAL_BILDURL."</b></td><td><input class='text' type='text' name='flayer' size='40' value='".$row['flayer']."'></td></tr>";
echo "</table>";

echo "<input type=hidden name=valid value='yes'>";
if ($ok == mod) {
echo "<input type='hidden' name='pa' value='ModifEvent'><input class='button' type='submit' value=\""._MODIFY."\">";
} else {
echo "<input type='hidden' name='pa' value='Valid'><input class='button' type='submit' value=\""._VALID."\">";
}
echo "</form>";
CloseTable();
xoops_cp_footer();
?>	