<?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: remind.php,v 1.1 2004/02/06 21:22:09 nobse Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Nobse
// Author Website : http://www.e-xoops.de
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include("header.php");

function remindadd() {
global $_GET, $db, $bcoosConfig;
$tid   = $_GET['id'];
$month = $_GET['month'];
$year  = $_GET['year'];

$query = $db->query("SELECT * FROM ".$db->prefix("ecal")." WHERE id = $tid");
$row = $db->fetchArray($query);
$tagebis = strtotime($row['stamp']) - time();
$tagebis = date("d",$tagebis);
$datum  = strftime(_EVEDATESHORT,strtotime($row['stamp']));

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

echo "<table width='100%' class='bg2' border='0'><tr>";
echo "<td width='40%'><b>"._CAL_DATE."</b>".$datum."</a></td>";
echo "<td width='60%'><b>"._TITLE.':'."</b> ".$row['subject']."</td></tr></table>";

echo "<form name='remind' method='post' action='remind.php'>";
echo "<table width='100%' class='bg3' border='0'><tr>";
echo "<td>"._CAL_REMIND."</td></tr>";
echo "<tr><td>"._CAL_REMIND_TEXT."<select class='select' name='remindday'>";
for ($xx=1; $xx<$tagebis; $xx++) {
	echo "<option value='$xx'>$xx</option>"; 
}
echo "</td></select>";
echo "<input type='hidden' name='tid' value='$tid'>";
echo "<input type='hidden' name='stamp' value='".$row['stamp']."'>";
echo "<input type='hidden' name='op' value='remindsave'>";
echo "</tr><td><center><input type='image' src='".XOOPS_URL."/modules/ecal/language/".$bcoosConfig['language']."/images/icon_remind_save.gif'></td></tr>";
echo "</form><tr><td><center>";
form_ret_ecal($month,$year);
echo "</center></td></tr></table>";

CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
}
//*******************************************************+
function remindsave() {
global $_POST, $xoopsUser, $db, $bcoosConfig;
$tid  		= $_POST['tid'];
$stamp   	= strtotime($_POST['stamp']);
$remindday  = $_POST['remindday'];

$remindday = strtotime("-$remindday Day",$stamp);
$userid = $xoopsUser->getvar("uid");

$newid = $db->genId($db->prefix('ecal_remind')."_id_seq");
$temp = $db->query("INSERT INTO ".$db->prefix("ecal_remind")." SET id=$newid, tid=$tid, uid = $userid, date= $remindday  ");
	
redirect_header("index.php",1,_CAL_REMIND_ADD);
}

//*************************************+
$op = !empty($_POST['op']) ? $_POST['op'] : $_GET['op'];
if ($xoopsUser) {
    
	switch ($op) {
	case "remindsave":
		remindsave();
		break;
	case "remindadd":
		remindadd();
		break;
	default:
		redirect_header("index.php");
		break;
	}
} else {
redirect_header("../../user.php",1,_NOACTION);
}
?>