<?
  include "../../mainfile.php";
?>
<?
  $teaid = $_POST["selTea"];
  $datefrom = $_POST["txtDatefrom"];
  $event = $_POST["selEvent"];
  $desc = $_POST["txtDesc"];
?>
<?
  $qchk = "SELECT * FROM xoops_pc_remarkrecord WHERE staffId='$teaid' AND remarkDate='$datefrom'";
  $rchk = mysql_query($qchk);
  $nchk = mysql_num_rows($rchk);
  if($nchk>0){
    $desc_old = mysql_result($rchk,0,"notice");
  }
?>
<?
  if($nchk>0){
  ?>
  <script>
    var answer = confirm(" Request already sent.\n Existing request: '<?= $desc_old ?>' \n Are you sure want to replace existing request?");
	if(answer){
	  alert("Request Updated");
      window.location="rmkrequp2.php?eid=<?= $event ?>&ntc=<?= $desc ?>&tid=<?= $teaid ?>&dte=<?= $datefrom ?>";
	}else{
	  alert("Request Cancelled");
	}
  </script>
  <?
  }else{
    $query = "INSERT INTO xoops_pc_remarkrecord 
               (staffId,remarkDate,remarkDatetil,eventId,notice,status)
			  VALUES
			   ('$teaid','$datefrom','$datefrom','$event','$desc',0)";
    mysql_query($query);
  ?>
  <?
  }
?>
  <script language="javascript">
    window.location="main.php?pg=rmk&ac=req";
  </script>
