<?php
session_start();                      
$username=$_SESSION['username'] ?? '';
$password=$_SESSION['password'] ?? '';
$chn=$_GET['chn'] ?? '';
$xid=$_GET['chn'] ?? '';
$xcyc=$_GET['cyc_no'] ?? '';

$ip=$_SERVER['REMOTE_ADDR'] ?? '';
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>
<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>
<style>
#Image {
    margin: 5px;
    border:2px solid #FF3399;
    border-radius: 5px;
    background-size: 210px;
    background-position:center;
}
#Imagex {
    margin: 5px;
    border:2px solid #FF3399;
	width:200px;
	height:200px;
    border-radius: 10px;
    background-size: 210px;
    background-position:center;
}
</style>

<script>
$(function() {
$( "#DPC_date1" ).DPC_date1({ dateFormat: 'dd/mm/yyyy' });
});
$(function() {
$( "#DPC_date2" ).DPC_date2({ dateFormat: 'dd/mm/yyyy' });
});
$(function() {
$( "#DPC_date3" ).DPC_date3({ dateFormat: 'dd/mm/yyyy' });
});
</script>
  <script type="text/javascript" src="datepickercontrol.js"></script>
  <script language="JavaScript">
     if (navigator.platform.toString().toLowerCase().indexOf("linux") != -1){
	 	document.write('<link type="text/css" rel="stylesheet" href="datepickercontrol_lnx.css">');
	 }
	 else{
	 	document.write('<link type="text/css" rel="stylesheet" href="datepickercontrol.css">');
	 }
    </script>

	<style type="text/css">
	INPUT { margin-right: 1em }
	</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>

	<script type="text/javascript">
<!--
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
//-->
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
function tubx() {
var prm1=document.getElementById("container_no").value;
var prm2=document.getElementById("canistr_no").value;
var prm3=document.getElementById("lift_no").value;
var prm4=document.getElementById("vial_postn").value;
var chn=document.getElementById("chn").value;
var cyc=document.getElementById("cyc").value;
var don_cyc=document.getElementById("don_cyc").value;
var semen_id=document.getElementById("semen_id").value;
var brcd1=document.getElementById("brcd1").value;
	$.ajax({
	type: 'POST',
	url: 'storgloc.php',
	//data: $('urfrm').serialize(),
	data: { 'chn': chn, 'cyc': cyc, 'don_cyc': don_cyc, 'semen_id': semen_id, 'container_no': prm1, 'canistr_no': prm2, 'lift_no': prm3, 'vial_postn': prm4, 'brcd1':brcd1, 'pmark':'1' },
	dataType: 'json',
	success: function ( data ) {
	}
	});
	alert("done successfully");
	document.getElementById("x1x").style.display = 'none';
	document.getElementById("x2x").style.display = 'none';
}
</script>
<script>
function tubx2() {
//var prm1=document.getElementById("container_no").value;
//var prm2=document.getElementById("canistr_no").value;
//var prm3=document.getElementById("lift_no").value;
//var prm4=document.getElementById("vial_postn").value;
var chn=document.getElementById("chn").value;
var cyc=document.getElementById("cyc").value;
var don_cyc=document.getElementById("don_cyc").value;
var semen_id=document.getElementById("semen_id").value;
var brcd1=document.getElementById("brcd1").value;
	$.ajax({
	type: 'POST',
	url: 'storgloc.php',
	//data: $('urfrm').serialize(),
	data: { 'chn': chn, 'cyc': cyc, 'don_cyc': don_cyc, 'semen_id': semen_id, 'brcd1':brcd1, 'pmark':'2' },
	dataType: 'json',
	success: function ( data ) {
	}
	});
	alert("done successfully");
document.getElementById("x1x").style.display = 'none';
document.getElementById("x2x").style.display = 'none';
}
</script>

<script>
function tuby() {
var prm1=document.getElementById("frzcontnr").value;
var prm2=document.getElementById("frzcanistr").value;
var prm3=document.getElementById("frzgloblt").value;
var prm4=document.getElementById("frzgloblt1").value;
var chn=document.getElementById("chn").value;
var cyc=document.getElementById("cyc").value;
var don_cyc=document.getElementById("don_cyc").value;
var semen_id=document.getElementById("semen_id").value;
var brcd2=document.getElementById("brcd2").value;

	$.ajax({
	type: 'POST',
	url: 'storgloc_eg.php',
	//data: $('urfrm').serialize(),
	data: { 'chn': chn, 'cyc': cyc, 'don_cyc': don_cyc, 'semen_id': semen_id, 'frzcontnr': prm1, 'frzcanistr': prm2, 'frzgloblt': prm3, 'frzgloblt1': prm4, 'brcd2':brcd2, 'pmark':'1' },
	dataType: 'json',
	success: function ( data ) {
	}
	});
	alert("done successfully");
document.getElementById("y1y").style.display = 'none';
document.getElementById("y2y").style.display = 'none';
}
</script>
<script>
function tuby2() {
//var prm1=document.getElementById("frzcontnr").value;
//var prm2=document.getElementById("frzcanistr").value;
//var prm3=document.getElementById("frzgloblt").value;
//var prm4=document.getElementById("frzgloblt1").value;
var chn=document.getElementById("chn").value;
var cyc=document.getElementById("cyc").value;
var don_cyc=document.getElementById("don_cyc").value;
var semen_id=document.getElementById("semen_id").value;
var brcd2=document.getElementById("brcd2").value;

	$.ajax({
	type: 'POST',
	url: 'storgloc_eg.php',
	//data: $('urfrm').serialize(),
	data: { 'chn': chn, 'cyc': cyc, 'don_cyc': don_cyc, 'semen_id': semen_id, 'brcd2':brcd2, 'pmark':'2' },
	dataType: 'json',
	success: function ( data ) {
	}
	});
	alert("done successfully");
document.getElementById("y1y").style.display = 'none';
document.getElementById("y2y").style.display = 'none';
}
</script>

<script>
function enblbtns_x() {
var brcd1lngth=document.getElementById("brcd1").value.length;
	if(brcd1lngth>9){
	document.getElementById("x1x").style.display = 'inline';
	document.getElementById("x2x").style.display = 'inline';
	document.getElementById("brcd1").style.display = 'none';
	}else{
	document.getElementById("x1x").style.display = 'none';
	document.getElementById("x2x").style.display = 'none';
	}
}
</script>
<script>
function enblbtns_y() {
var brcd1lngth=document.getElementById("brcd2").value.length;
	if(brcd1lngth>9){
	document.getElementById("y1y").style.display = 'inline';
	document.getElementById("y2y").style.display = 'inline';
	document.getElementById("brcd2").style.display = 'none';
	}else{
	document.getElementById("y1y").style.display = 'none';
	document.getElementById("y2y").style.display = 'none';
	}
}
</script>

</head>
<body>
<?php
include 'dbcon.php';

$result = mysqli_query($conn, "SELECT * FROM cycle_lst where pat_mrn like '%$xid%' and chn_id='$xcyc'");
$row = $result ? mysqli_fetch_assoc($result) : null;
$row = $row ?: [];
$don_protocl=$row['cycle_donorid'] ?? '';

$datex=$row['cycle_opudt'] ?? '';
if($datex=='0000-00-00'){
$datex_1='';
}else{
$datex_1=$datex ? date("d/m/Y", strtotime($datex)) : '';
}

$datey=$row['cycle_clsngdt'] ?? '';
if($datey=='0000-00-00'){
$datex_2='';
}else{
$datex_2=$datey ? date("d/m/Y", strtotime($datey)) : '';
}

$datez=$row['cycle_clsngdt'] ?? '';
if($datez=='0000-00-00'){
$datex_3='';
}else{
$datex_3=$datez ? date("d/m/Y", strtotime($datez)) : '';
}

?>
<div align="left">
<form id="aspir_main" name="aspir_main" method="post" action="aspir_update.php?pat_chn=<?php echo $xid; ?>&cyc=<?php echo $xcyc; ?>" onKeyPress="return event.keyCode != 13;">
<input name="chn" id="chn" type="hidden" value="<?php echo $xid; ?>"/>
<input name="cyc" id="cyc" type="hidden" value="<?php echo $xcyc; ?>"/>

<table width="80%" align="left">
<tr>
<td colspan="4" bgcolor="#E0EFFC"><div align="left">
<strong>Cycle Parameter | <?php echo $chn;?></strong></td></tr>
  <tr><td width="50%" colspan="4" bgcolor="#E0EFFC">Pickup Date :
				<input type="hidden" id="DPC_TODAY_TEXT" value="today">
<input type="hidden" id="DPC_BUTTON_TITLE" value="Open calendar...">
<input type="hidden" id="DPC_MONTH_NAMES" value="['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']">
<input type="hidden" id="DPC_DAY_NAMES" value="['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']">
  <input type="text" name="DPC_date1" id="DPC_date1" size="8" value="<?php echo $datex_1; ?>">	
  Transfer Date :
						<input type="hidden" id="DPC_TODAY_TEXT" value="today">
<input type="hidden" id="DPC_BUTTON_TITLE" value="Open calendar...">
<input type="hidden" id="DPC_MONTH_NAMES" value="['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']">
<input type="hidden" id="DPC_DAY_NAMES" value="['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']">
  <input type="text" name="DPC_date2" id="DPC_date2" size="8" value="<?php echo $datex_2; ?>">		</td>

  </tr>
  <tr>
    <td colspan="4" bgcolor="#E0EFFC">
      Donor protocol 
      <input type="text" name="don_cyc" size="12" value="<?php echo $row['cycle_donorid'] ?>">
	  Semen ID 
      <input type="text" name="semen_id" size="12" value="<?php echo $row['cycle_semenid'] ?>">	  	  </td>
    </tr>
  <tr>
    <td colspan="4" bgcolor="#E0EFFC">Procedure Markup 
        <select name="etprocedurelab">
		<?php $tagx=$row['etprocedurelab'];
		if($tagx=="1"){
		$tagy="No ET";
		}elseif($tagx=="2"){
		$tagy="All Freeze";
		}elseif($tagx=="3"){
		$tagy="ET";
		}else{
		$tagy="";
		}?>
		
    <option value="<?php echo $tagy ?>"><?php echo $tagy ?></option>
    <option value=""></option>
    <option value="1">No ET</option>
    <option value="2">All Freeze</option>
    <option value="3">ET</option>
        </select>
    </div></td>
    </tr>
  <tr>
  <tr>
    <td colspan="4" bgcolor="#FFEAEA"><br><strong>Sperm Inward - Outward</strong>
	<table><tr><td><td><input type="text" name="brcd1" id="brcd1" size="12" OnKeyUp="enblbtns_x()">
	<div id="x1x" style="display:none">
	<a href="#" id="x1" onClick="tubx()" class="btn-two green small">Witness - Inward - Storage</a></div></td>
	<td><div id="x2x" style="display:none"><a href="#" id="x2" onClick="tubx2()" class="btn-two green small">Witness - Outward - Storage to procedure</a></div></td>
	</td></tr></table>
	</td>
    </tr>
  <tr>
    <td colspan="4" bgcolor="#FFE8FF"><br><strong>Egg Inward - Outward</strong>
	<table><tr><td>
	<td>
	<input type="text" name="brcd2" id="brcd2" size="12" OnKeyUp="enblbtns_y()">
	<div id="y1y" style="display:none"><a href="#" id="y1" onClick="tuby()" class="btn-two green small">Witness - Inward - Dish to straw</a></div></td>
	<td><div id="y2y" style="display:none"><a href="#" id="y2" onClick="tuby2()" class="btn-two green small">Witness - Outward - Straw to dish</a></div></td>
	</td></tr></table></td>
    </tr>
  <tr>
    <td colspan="4"><input type="submit" value="Update Aspiration" name="up_aspir_btn" class="btn-two red small"> <a href="gend_cycle_select.php?chn=<?php echo $chn;?>" class="btn-two blue small">Back to patient main screen</a></td>
    </tr>
</table>
</form>
</div>
</body>
</html>
