<?php
session_start();                      
$username=$_SESSION['username'] ?? null;
$password=$_SESSION['password'] ?? null;
$chn=strtoupper($_GET['chn']);
$xcyc=$_GET['cyc_no'] ?? null;
$rec_id = $_GET['actvty_id'] ?? null;
$ip=$_SERVER['REMOTE_ADDR'] ?? null;
include 'dbcon.php';
$password=md5($password);
$sql = mysqli_query($conn, "SELECT * FROM matcher_usermst WHERE nif_usr='$username' AND nif_pass='$password' AND act_vate='1'");
$login_check = mysqli_num_rows($sql);
if($login_check > 0){
}else {
	session_destroy();
echo ("<SCRIPT LANGUAGE='JavaScript'> window.location.href='invalidlogin.html'; </SCRIPT>");
}
?>
<!DOCTYPE HTML>
<html>
<head>

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
	<style type="text/css">
	INPUT { margin-right: 1em }
	</style>
<link href="../style.css" rel="stylesheet" type="text/css" />
<link href="style_btn.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js_button.js"></script>
<link href="../style_btn.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="../js_button.js"></script>
<script>
function getInputValuesame(){
document.getElementById("extnd_duedt").value = document.getElementById("regdt").value;
}
function getInputValue1(){
document.getElementById("extnd_duedt").value = document.getElementById("year1").value;
}
function getInputValue2(){
document.getElementById("extnd_duedt").value = document.getElementById("year2").value;
}
function getInputValue3(){
document.getElementById("extnd_duedt").value = document.getElementById("year3").value;
}
function getInputValue5(){
document.getElementById("extnd_duedt").value = document.getElementById("year5").value;
}
</script>
<body>
<form name ="rec_updt" id="rec_updt" method="POST" action="actvcty_extnd_updt_embryo.php">
<?php
				$query  = "SELECT * FROM actvty_trans_frzng_embryo where log_no='$rec_id'";
				$result = mysqli_query($conn, $query);
				while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
?>
<input type="hidden" name="log_no"  size="25" value="<?php echo $row['log_no'] ?>">
<input type="hidden" name="chn"  size="25" value="<?php echo $row['pat_id'] ?>">
<input type="hidden" name="cycle_no"  size="25" value="<?php echo $row['cycle_id'] ?>">
<input type="hidden" name="strownos"  size="25" value="<?php echo $row['strow_no'] ?>">
<input type="hidden" name="contnrno"  size="25" value="<?php echo $row['contnrno'] ?>">
<input type="hidden" name="canistrno"  size="25" value="<?php echo $row['canistrno'] ?>">
<input type="hidden" name="goblet"  size="25" value="<?php echo $row['goblet'] ?>">
<input type="hidden" name="cryocolor"  size="25" value="<?php echo $row['cryocolor'] ?>">
<table align="center" style="width:50%;" border="0">
  <tr>
    <td colspan="2"><strong>Extend freezing validity</strong></td>
  </tr>
  <tr>
    <td colspan="2">Patient : <?php echo $row['pat_id'] ?></td>
  </tr>
  <tr>
    <td>Due Date</td>
    <td><input type="text" name="act_duedt"  size="25" value="<?php echo $row['term_date'] ?>" style='width:160px;height:28px;'>
</td>
  </tr>
  <tr>
    <td>Extend to Date</td>
    <td><input type="text" name="extnd_duedt" value="" size="25" style='width:160px;height:28px;'>
</td>
  </tr>
  <tr>
    <td valign="middle"></td>
    <td valign="middle"><input type="button" name="clickme1" id="clickme1" value="Same year" onClick="getInputValuesame()">
	<input type="button" name="clickme1" id="clickme1" value="1 Year" onClick="getInputValue1()">
	<input type="button" name="clickme2" id="clickme2" value="2 Year" onClick="getInputValue2()">
	<input type="button" name="clickme3" id="clickme3" value="3 Year" onClick="getInputValue3()">
	<input type="button" name="clickme5" id="clickme5" value="5 Year" onClick="getInputValue5()">
	<input type="hidden" name="year1" id="year1" value="<?php echo date('Y-m-d', strtotime($row['term_date']. '+ 1 year'));?>">
	<input type="hidden" name="year2" id="year2" value="<?php echo date('Y-m-d', strtotime($row['term_date']. '+ 2 year'));?>">
	<input type="hidden" name="year3" id="year3" value="<?php echo date('Y-m-d', strtotime($row['term_date']. '+ 3 year'));?>">
	<input type="hidden" name="year5" id="year5" value="<?php echo date('Y-m-d', strtotime($row['term_date']. '+ 5 year'));?>">
	</td>
  </tr>
  <tr>
    <td>Remark if any</td>
    <td><input type="text" name="act_rem"  size="25" style='width:160px;height:28px;'>
</td>
  </tr>
  <tr>
    <td><input type="submit" name="Submit" value="Submit" class="button special" onClick="this.disabled=true;this.form.submit();"/></td>
    <td><a href="frzmodls.php?chn=<?php echo $chn;?>&cyc_no=<?php echo $xcyc;?>" class="btn-two blue small">&nbsp;Back to freezing dashboard&nbsp;</a></td>
    </tr>
  </table>
<?php }
?></form>
</body>
</html>
