<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
 * The contents of this file are subject to the SugarCRM Public License Version
 * 1.1.3 ("License"); You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 ********************************************************************************/
/*********************************************************************************

 ********************************************************************************/
require_once('modules/EcmReminders/ReminderHelper.php');
require_once('XTemplate/xtpl.php');
$xtpl = new XTemplate ('modules/EcmReminders/ReminderWindow1.html');

global $mod_strings, $app_strings;

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

if(count($meetings)+count($calls)+count($ecmreminders)==0)
{
	$list='<script></script>';
}
else
{

	for($i=0;$i<count($ecmreminders);$i++)$name[]=$ecmreminders[$i];
	rsort($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>';

$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");
?>
