<?
require_once('modules/EcmReminders/ReminderHelper.php');
require_once('XTemplate/xtpl.php');
$xtpl = new XTemplate ('modules/EcmReminders/ReminderWindow.html');

global $mod_strings, $app_strings;

$meetings=getList("meetings","Held"," and reminder_time!='-1'","date_start","date_start","Meetings",0);
$calls=getList("calls","Held"," and reminder_time!='-1'","date_start","date_start","Calls",0);
//$tasks=getList("tasks","Completed","","date_start","date_start","Tasks");
$ecmreminders=getList("ecmreminders","Held"," and reminder_time!='-1'","date_start","date_start","EcmReminders",1);

if(count($meetings)+count($calls)+count($ecmreminders)==0)
{
	$list='<script>window.close();</script>';
}
else
{
	for($i=0;$i<count($meetings);$i++)$name[]=$meetings[$i];
	for($i=0;$i<count($calls);$i++)$name[]=$calls[$i];
	//for($i=0;$i<count($tasks);$i++)$name[]=$tasks[$i];
	for($i=0;$i<count($ecmreminders);$i++)$name[]=$ecmreminders[$i];

	rsort($name);
	//print_r($name);
	$list=ListView($name);
}
$js='
function selectallitems()
{';
	if(count($name)>0)
	{
	foreach($name as $value)
	{
		$js.='if(document.getElementById("selectall").checked==true){document.getElementById("check'.$value['id'].'").checked=true}else {document.getElementById("check'.$value['id'].'").checked=false} ;
		';
	}
	}
$js.='
}';
$javascript='';
$javascript.='
<script>
'.$js.'
function show(id,date,hour,minute)
{
	document.getElementById("date").value=date;
	document.getElementById("hour").value=hour;
	document.getElementById("minute").value=minute;
}
function showdiv(id)
{
	document.getElementById("postponeTo").style.display="none";
	document.getElementById("postponeBy").style.display="none";
	document.getElementById("li_postponeTo").className="";
	document.getElementById("li_postponeBy").className="";
	document.getElementById("a_postponeTo").className="";
	document.getElementById("a_postponeBy").className="";
	document.getElementById(id).style.display="block";
	document.getElementById("li_"+id).className="active";
	document.getElementById("a_"+id).className="current";
}
</script>';

$hour='<select name="hour" id="hour">';
for($i=0;$i<=23;$i++)
{
	if($i<=9)$value="0".$i;
	else $value=$i;
	$hour.='<option value="'.$i.'"';
	if($i==$_SESSION['reminder']['hour'])$hour.=' selected';
	$hour.='>'.$value.'</option>';
}
$hour.='</select>';

$mins=array(0,15,30,45);
$minute='<select name="minute" id="minute">';
for($min=0;$min<60;$min++)
{
	if($min==0)$value="00";
	else $value=$min;
	$minute.='<option value="'.$min.'"';
	if($min==$_SESSION['reminder']['minute'])$minute.=' selected';
	$minute.='>'.$value.'</option>';
}
$minute.='</select>';
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign("DATE_START",$_SESSION['reminder']['date']);
$xtpl->assign("LIST",$list);
$xtpl->assign("HOUR",$hour);
$xtpl->assign("MINUTE",$minute);
$xtpl->assign("JAVASCRIPT",$javascript);

$xtpl->parse("main");
$xtpl->out("main");
?>