<?php
session_start();                      
$username=$_SESSION['username'] ?? '';
$password=$_SESSION['password'] ?? '';

$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){
	$row = mysqli_fetch_assoc($sql);
	$xadmnchk=$row['dept_x'];
//	if($creat_pt_chk=="1"){
//	$xadmnchk = "<a href='strt_case.php' target='_self' class='btn-two purple large'>Create New Patient</a>";
//	}else{
//	$xadmnchk = "<a href='strt_case.php' target='_self' class='btn-two purple large'>Create New Patient</a>";
//	}

}else {
echo ("<SCRIPT LANGUAGE='JavaScript'>
	window.alert('You are not authorised to view this page');
    </SCRIPT>");
	session_destroy();
    echo ("<SCRIPT LANGUAGE='JavaScript'> window.location.href='http://ivftech.in/index.html'; </SCRIPT>");
}

?>
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<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>

<link rel='stylesheet' href='css/jquery-ui-custom.css'/>
<link rel='stylesheet' href='css/ui.jqgrid.css'/>

<script src='js/jquery-1.9.0.min.js'></script>
<script src='js/grid.locale-en.js'></script>
<script src='js/jquery.jqGrid.min.js'></script>
	<style type="text/css">
	INPUT { margin-right: 1em }
	</style>
<link href="../style.css" rel="stylesheet" type="text/css" />

</head>
<body>
<div class='wrapper' align="center">
<br>
<div align="center" style="width:98%;margin-left:10px;margin-right:0px">
<p style="font-size:22px;color:#FF0000">Kalyan Nagar</p>
<?php
if($xadmnchk=="1"){
echo "<a href='witnsexprt_taggen.php' target='_self' class='btn-two yellow large'>Export tag generation</a><a href='witnsexprt.php' target='_self' class='btn-two green large'>Export Witness</a>";
}else{
}
$myfilex = fopen("txfd735.txt", "w") or die("Unable to open file!");
$txtx = "";
fwrite($myfilex, $txtx);
fclose($myfilex);
$myfilex = fopen("txfd735a.txt", "w") or die("Unable to open file!");
$txtx = "";
fwrite($myfilex, $txtx);
fclose($myfilex);
?>
</div>

<table><tr><td valign="middle"><input type="text" style="text-align:left;width:260px;" id="item" onKeyDown="doSearch(arguments[0]||event)" placeholder="Search Patient ID or Name"/><br><br>
</td>
<td></td><br>
        <div class='wrapper'>
              <table id="rowed2" style="font-size:18px;"></table>
          <div id="prowed2"></div>
        </div>
        <script>
	
	jQuery("#rowed2").jqGrid({
    url:'server.php',
    datatype: "json",

    jsonReader: {
        repeatitems: true,
        root: "rows",
        page: "page",
        total: "total",
        records: "records",
        id: "id"
    },
   	 colNames:['MRN','Cycle Start Date', 'Treatment', 'Patient Name','Partner Name'], 
	   colModel:[ 
	   {name:'pat_mrn',index:'pat_mrn', width:120,sortable:true}, 
	   {name:'cycle_strtd',index:'cycle_strtd', width:140,sortable:true,editable:false},
	   {name:'cycle_type',index:'cycle_type', width:140,sortable:true,editable:false},
	   {name:'pat_name',index:'pat_name', width:280,sortable:true,editable:false}, 
	   {name:'part_name',index:'part_name', width:280,sortable:true,editable:false} 
	   ],
   	rowNum:15,
   	rowList:[15,25,35],
   	pager: '#prowed2',
   	sortname: 'chn_id',
    viewrecords: true,
	height:'100%',
    sortorder: "asc",
	autowidth: true,

	gridComplete: function(){
		var ids = jQuery("#rowed2").jqGrid('getDataIDs');
		for(var i=0;i<ids.length;i++){
			var cl = ids[i];
			be = "<input style='height:22px;width:40px;' type='button' value='Edit' onclick=\"jQuery('#rowed2').jqGrid('editRow','"+cl+"');\"  />"; 
			se = "<input style='height:22px;width:40px;' type='button' value='Save' onclick=\"jQuery('#rowed2').jqGrid('saveRow','"+cl+"');\"  />"; 
			ce = "<input style='height:22px;width:50px;' type='button' value='Cancel' onclick=\"jQuery('#rowed2').jqGrid('restoreRow','"+cl+"');\" />"; 
			jQuery("#rowed2").jqGrid('setRowData',ids[i],{act:be+se+ce});
		}	
	},
	editurl: "update22.php"
});

var timeoutHnd; 
var flAuto = true;
 function doSearch(ev){ 
 if(!flAuto)return; 
 if(timeoutHnd) clearTimeout(timeoutHnd);
  timeoutHnd = setTimeout(gridReload,500);
 }
function gridReload(){
 var nm_mask = jQuery("#item").val();
jQuery("#rowed2").jqGrid('setGridParam',{url:"server.php?nm_mask="+nm_mask,page:1}).trigger("reloadGrid");   
}	   	   
	      </script>
  </div>
</body>
</html>

