<?php 
session_start();
include "./connection.php";
$opt = $_REQUEST["opt"];
$option=$_REQUEST["option"];

if($option==="disposed")
{ 
	if($opt==="5"){$q1="SELECT * FROM tbl_disposals WHERE status='1' AND court_id='".$_SESSION["court_id"]."' LIMIT 5";	}
		if($opt==="50"){$q1="SELECT * FROM tbl_disposals WHERE  status='1' AND court_id='".$_SESSION["court_id"]."'LIMIT 50";	}
			if($opt==="100"){$q1="SELECT * FROM tbl_disposals WHERE status='1'AND court_id='".$_SESSION["court_id"]."' LIMIT 100";	}
				if($opt==="all"){$q1="SELECT * FROM tbl_disposals WHERE status='1'AND court_id='".$_SESSION["court_id"]."' ";	}
 
		    $result=$conn->query($q1);
		    if (!empty($result) && $result->num_rows > 0)
		     {
				echo ' <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>';
				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>';
				 
				  
				}

    		 }

}
if($option==="restored")
{
if($opt==="5"){$q121="SELECT * FROM tbl_disposals WHERE court_id='".$_SESSION["court_id"]."' AND status='1' LIMIT 5" ;	}
if($opt==="50"){$q121="SELECT * FROM tbl_disposals WHERE court_id='".$_SESSION["court_id"]."' AND status='1'LIMIT 50";	}
if($opt==="100"){$q121="SELECT * FROM tbl_disposals WHERE court_id='".$_SESSION["court_id"]."' AND status='1'LIMIT 100";	}
if($opt==="all"){$q121="SELECT * FROM tbl_disposals WHERE court_id='".$_SESSION["court_id"]."' AND status='1'";	}
    		 	
		    $result21=$conn->query($q121);
		    if (!empty($result21) && $result21->num_rows > 0)
		     {
				 echo '<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>';
				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>';
				 
				  }
				}
    		 }
}
 ?>