<?php
 session_start();
 if($_SESSION["Logdin"]===false)
{
    header("Location:login.php");
    exit();
}
include './connection.php';
include "header.php";
?>
<html>
<head>
	<script>
	function showcases(str) {
	var opt=str; 
  if (str.length == 0) {
   alert("Choose Correct One.");
    return;
  } else {
    const xmlhttp = new XMLHttpRequest();
    xmlhttp.onload = function() {
    document.getElementById("cont").innerHTML = this.responseText;
     
    }
  xmlhttp.open("GET", "./loadcases.php?opt="+opt);
  xmlhttp.send();
  }
}


function show()
{
    if(document.getElementById('cty').value=='2')
    {
        document.getElementById('ccase').style.display='';
         
        
    }else{ document.getElementById('ccase').style.display='none';
        }
}
 
</script>
	<title>Add New</title>
</head>
<body>

 

<div style="justify-content: center;text-align: center;">

	<h4>Hello! <?php echo $_SESSION["user_name"];?> You are working as <?php echo $_SESSION["user_type"]." to the Court of <u>".$_SESSION["court_name"]."</u>";?></h4>

<form method="post" action="addnew_php.php">
 <select id="cty" name="caset" style="border-radius: 7px;border-color: navy;padding-top: 3px;padding-bottom: 3px;margin-right: 18px;margin-left: 14px;"  onchange="show(this.value)"><option value="1">Civil</option><option value="2">Criminal</option></select>
   <input placeholder="مقدمہ نمبر" class="txt"type="text" name="caseno" required="" minlength="2" maxlength="12" style="width: 140px;" ><br>

 رجوعہ<br></td><td><input class="txt" type="date" name="instdate"placeholder="Institution Date" required=""  ><br> 
 <div id="ccase" style="display:none;">
     <input type="text"   name="firno" class="txt" placeholder="FIR/Mad No"  maxlength="6"> <br>
 <input type="text"  name="fps" class="txt" placeholder="Police Station"><br>FIR Date: &nbsp;
 <input type="date" class="txt"  name="fdate" style="width:100px; " placeholder="FIR Date">
 </div>
 
<input style="width:90px;" class="txt" type="text"placeholder="فریق اول" name="f1" required="" minlength="6" maxlength="100"    >بنام<input class="txt" minlength="6" name="f2"placeholder="فریق ثانی " class="txt" style="width:90px;"><br>
<input placeholder="نوعیت/جرم لکھیں" name="casetype" type="text"  class="txt" required=""  style="text-align: left;"  > 

<br> 
آج کی کاروائی
<br>
<select name="proceed"  class="txt" required="" style="text-align: right; padding-right: 4px;"> <?php
$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>';
}
     }

       ?>
</select>
 <br> 


<button style="border-color: green;border-radius: 7px;padding-top: 2px;padding-bottom: 1px;">درج کریں</button>
</form>
</div> 

Show :<select  onchange="showcases(this.value);" style="margin-bottom: 5px;max-width: 150px;" class="txt" id="opt"><option value="20">Show top: 20</option><option value="50">Show top:50</option><option value="all">Show all the cases</option></select>

<table id="cont" style="width: 95%;float: center;text-align: center;border:1px solid navy; ">
<?PHP
  
 
  $qQQ="SELECT * FROM caseinfo WHERE currentcourtid='".$_SESSION["court_id"]."' AND status='1' LIMIT 20";
  
 
    $resultQ=$conn->query($qQQ);
    if (!empty($resultQ) && $resultQ->num_rows > 0)
     {
 echo ' <tr style="background-color: darkgreen;color: white;">
    <th>مقدمہ نمبر</th>
    <th>رجوعہ</th>
    <th>عنوان مقدمہ</th>
    <th>نوعیت</th>
    <th>Update</th>
     
  </tr>';
while( $rowQ=$resultQ->fetch_assoc())
{
       echo "<tr>";

    echo '<td>'.$rowQ["caseno"].'</td>';
    echo '<td>'.$rowQ["instdate"].'</td>';
    echo '<td>'.$rowQ["casetitle"].'</td>';
    echo '<td>'.$rowQ["casetype"].'</td>';
    echo '<td><a href="caseupdate.php?id='.$rowQ["ID"].'" style="color:darkgreen;">Update</a></td>';
 
    echo "</tr>";
}
     }


 ?>

</table>
</body>

</html>
<style type="text/css">
	
	.txt{
		border-radius: 7px;
		border-color: blue;
		padding-bottom: 4px;
		padding-top: 2px;
		width: 250px;
		margin-left: 15px;

	}   
	body{
    font-family: jameel noori nastaleeq ;

}
a,h4{
 
	font-family: Times New Roman ;
 
}
    table,   td {
  border: 1px solid black;
  border-collapse: collapse;
        }
th  {
  border: 1px solid black;
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 18px;
}
button:hover{background-color:green;color:white; }
button:active{background-color:red;}
	input havor{border-color: green;}

</style>
 
  
