<?php
session_start();
 if(empty($_SESSION["user_id"])||$_SESSION["Logdin"]===false||empty($_SESSION["court_id"]))
{
    header("Location:login.php");
    exit();
}
include './connection.php';
include "header.php";
?>
 <head>
 	
<script>
function showHint(str) {
var opt=	document.getElementById("opt").value;
  if (str.length == 0) {
    document.getElementById("val").innerHTML = "";
    return;
  } else {
    const xmlhttp = new XMLHttpRequest();
    xmlhttp.onload = function() {
      document.getElementById("reslt").innerHTML = this.responseText;
    }
  xmlhttp.open("GET", "./allrecord_php.php? q=" + str+"&opt="+opt);
  xmlhttp.send();
  }
}

 	function showcases(str,str1,str2) {
	var opt=str; 
	var option=str1;
  if (str.length == 0) {
   alert("Choose Correct One.");
    return;
  } else {
    const xmlhttp = new XMLHttpRequest();
    xmlhttp.onload = function() {
    document.getElementById(str2).innerHTML = this.responseText;
     
    }
  xmlhttp.open("GET", "./disposal_load.php?opt="+opt+"&option="+option);
  xmlhttp.send();
  }
}
 
 

</script>



<style type="text/css">
	    table,   td {
  border: 1px solid black;
  border-collapse: collapse;
        }
th  {
  border: 1px solid black;
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 18px;
}
td{
	padding-top: 3px;
	padding-bottom: 3px;
}
	.txt{
		border-radius: 7px;
		border-color: blue;
		padding-bottom: 4px;
		padding-top: 2px;
		width: 160px;
		margin-left: 15px;
		

	}
	button{
		border-color: navy;
		border-radius: 9px;
	}
 button:hover{background-color: green;color:white;}
  button:active{background-color: red;color:white;}
	input haver{border-color: green;}
}
</style>



 </head>

   


 


<div id="div3"  >
 <h3>Cases Can be Restored<select onchange="showcases(this.value,'restored','reslt2')" class="txt" style="width: 100px;"><option value="5">Top:5</option><option value="50">Top:50</option><option value="100">Top:100</option><option value="all">All</option></select></h3>
<table id="reslt2" style="width: 98%;text-align: center;border:1px solid navy">
	<tr style="background-color: darkgreen;color: white;">
				 
						<th>Case No</th>
					<th>Case Title</th>
					<th>Disposal Type</th>
					<th>Restore Date</th>
					<th>Next Date</th>
					<th>Next Proceeding</th>
					<th>Restore</th>
	</tr>
	<?php
 
			$q121="SELECT * FROM tbl_disposals WHERE court_id='".$_SESSION["court_id"]."' AND status='1' LIMIT 5";
		    $result21=$conn->query($q121);
		    if (!empty($result21) && $result21->num_rows > 0)
		     {
				 
				while( $row21=$result21->fetch_assoc())
				{
					if($row21["type"]==="Dismissed in Default"||$row21["type"]==="Adjourned Sine Die")
					{
						echo '<form action="./restore_php.php" method="POST">
						<input type="hidden" name="id" value="'.$row21["case_id"].'">
						<tr>';
							$q21="Select * from caseinfo WHERE ID=".$row21["case_id"]."";
							    $resul21=$conn->query($q21);
							    $r21=$resul21->fetch_assoc();
							echo '<td>'.$r21["caseno"].'</td>';
							echo '<td>'.$r21["casetitle"].'</td>';
								echo '<td>'.$row21["type"].'</td>';
							echo '<td><input required="" type="date" name="rdate" class="txt"></td>';
							echo '<td><input required="" type="date" name="pdate" class="txt"></td>';
							echo '<td><select name="proceed"  class="txt" required=""  "> ';
							$q2="Select * from courtproceedings";
						    $result1=$conn->query($q2);
						    if (!empty($result1) && $result1->num_rows > 0)
						     {

							while( $row1=$result1->fetch_assoc())
							{
						    echo '<option value="';echo $row1["proceedingtitle"];echo '">';echo $row1["proceedingtitle"]; echo '</option>';
							}
						     }
						     echo "</select></td>";

    

							echo '<td> <button>Restore</button> </td></tr></form>';
					}
				 			
				 
				  
				}
    		 }
    	?>

</table>
</div>

<h3>List of Disposed
<select onchange="showcases(this.value,'disposed','reslt1')" class="txt" style="width: 100px;"><option value="5">Top:5</option><option value="50">Top:50</option><option value="100">Top:100</option><option value="all">All</option></select></h3>
</h3><table id="reslt1" style="width: 98%;text-align: center;border:1px solid navy">
	<tr style="background-color: darkgreen;color: white;">
				 
				    <th>Case No</th>
					<th>Institution</th>
					<th>Case Title </th>
					<th>Disposal Type</th>
					<th>Disposal Date</th>
				 
	</tr>
	
	
	<?php
		 $q1="SELECT * FROM tbl_disposals WHERE status='1'AND court_id='".$_SESSION["court_id"]."' LIMIT 5 ";	 
 
		    $result=$conn->query($q1);
		    if (!empty($result) && $result->num_rows > 0)
		     {
		 
				while( $row1=$result->fetch_assoc())
				{
				 			 $qq="Select * from caseinfo WHERE ID=".$row["case_id"]."";
				 			   $resultq=$conn->query($qq);
				 			   $row=$resultq->fetch_assoc();
							echo '
							<tr><td>'.$row["caseno"].'</td>';
							echo '<td>'.$row["instdate"].'</td>';
							echo '<td>'.$row["casetitle"].'</td>';
							echo '<td>'.$row1["type"].'</td>';
							echo '<td>'.$row1["dated"].'</td></tr>';
				 
				  
				}

    		 }
	
	
	?>
 