<?php
// $Id: remind.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
// Author Website : http://www.e-xoops.de
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include("header.php");

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

$query = $db->query("SELECT * FROM ".$db->prefix("ecal")." WHERE id = $tid");
$row = $db->fetch_array($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>"._CAL_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/".$xoopsConfig['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 $HTTP_POST_VARS, $xoopsUser, $db, $xoopsConfig;
$tid  		= $HTTP_POST_VARS['tid'];
$stamp   	= strtotime($HTTP_POST_VARS['stamp']);
$remindday  = $HTTP_POST_VARS['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($HTTP_POST_VARS['op']) ? $HTTP_POST_VARS['op'] : $HTTP_GET_VARS['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);
}
?>