<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("../opendb.php");
include("../test.php");
if($save)
{
 $sql="create table reminder (brcode varchar(100),user varchar(100),date date,mesg varchar(250))";
 mysqli_query($db,$sql);
 $dt=parseDate($date1);
 $sql="insert into reminder values('$brcode','$user','$dt','$mesg')";
 mysqli_query($db,$sql) or die(mysqli_error());
}
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
th{background-color:c1d7bb;font-size:13}
.mnu{margin-left:5}
</style>
<center>

<SCRIPT LANGUAGE="JavaScript" SRC="PopupWindow.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="AnchorPosition.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="date.js"></SCRIPT>

<script>
var cal2 = new CalendarPopup();
cal2.showYearNavigation();

var cal3 = new CalendarPopup();
cal3.showYearNavigation();

var cal4 = new CalendarPopup();
cal4.showYearNavigation();

function valid()
{
 if(document.forms[0].date1.value.length<=0)
 {
   alert('Invalid Date');
   return false;
 }
 if(document.forms[0].mesg.value.length<=0)
 {
   alert('Invalid Message');
   document.forms[0].mesg.focus();
   return false;
 }
 return true;
}

</script>
<form action='<?print $PHP_SELF?>' onSubmit='return valid()'>
<table border=0>
<th colspan=4>Set a reminder</th>
<tr><td rowspan=3><img src=remind.gif></td></tr>
<tr><td>Select date<td width=50>
<INPUT TYPE="text" NAME="date1" VALUE="" SIZE=10 readonly> 
</td>
<td>
<A HREF="#" onClick="cal2.select(document.forms[0].date1,'anchor1','dd-MM-yyyy'); return false;" TITLE="Click for Calander" NAME="anchor1" ID="anchor1"><img src='cal.jpg' border=0></A>
</td>
<tr><td>Message</td><td colspan=2><textarea name='mesg' rows=5 cols=50></textarea></td></tr>
<th colspan=4><input type=submit value='Save' name='save'></td></tr>
</table>
</form>

<form action='<?print $PHP_SELF?>'>
<table border=0>
<th colspan=4>Search a reminder</th>
<tr><td>From <td width=50>
<td>dd <input type=text name=d1 size=2 value='1'>
mm <input type=text name=m1 size=2 value='<?print date('m')?>'>
yy <input type=text name=y1 size=4 value='<?print date('Y')?>'>
</tr>
<tr><td>To <td width=50>
<td>dd <input type=text name=d2 size=2 value='<?print date('d')?>'>
mm <input type=text name=m2 size=2 value='<?print date('m')?>'>
yy <input type=text name=y2 size=4 value='<?print date('Y')?>'>
</tr>
<th colspan=4><input type=submit value='Show' name='show'></td></tr>
</table>
</form>


<?
if($show)
{
 $df=$y1.'-'.$m1.'-'.$d1;
 $dt=$y2.'-'.$m2.'-'.$d2;

?>
<table cellpadding=3 cellspacing=1 BGCOLOR='GRAY'>
<th colspan=10 style="background-color:pink;LETTER-SPACING:2">REMINDER FROM TODAY ONWARDS</th>
<tr>
<th>No.<th>Date <th>Message
<?
$i=1;
$re=mysqli_query($db,"select * from reminder where brcode='$brcode' and user='$user' and date>='$df' and date<='$dt'");
while($row=mysqli_fetch_array($re))
{
 print "<tr bgColor='white'><td>".$i++."</td><td>".datetohtml($row[date])."</td><td>$row[mesg]</td></tr>";
}
?>
</table>

<br>
<?
}
?>
<table cellpadding=3 cellspacing=1 BGCOLOR='GRAY'>
<th colspan=10 style="background-color:pink;LETTER-SPACING:2">REMINDER FROM TODAY ONWARDS</th>
<tr>
<th>No.<th>Date <th>Message
<?
$i=1;
$re=mysqli_query($db,"select * from reminder where brcode='$brcode' and user='$user' and date>=curdate()");
while($row=mysqli_fetch_array($re))
{
 print "<tr bgColor='white'><td>".$i++."</td><td>".datetohtml($row[date])."</td><td>$row[mesg]</td></tr>";
}
?>
</table>

