<?
session_start();
include_once('includes/top.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='index.html'; </script>";
 return;
}

include("opendb.php");
include("test.php");
?>

<link rel="stylesheet" href="style.css" type="text/css" />
<style>
th{background-color:lightsteelblue;color:black}
//tr{background-color:white}
</style>
<center>

<?
if(isset($_POST['show']))
{
     $pstvl=$_REQUEST['pstvl'];
     
     
   if($pstvl=='Plant')
     { 
$result=mysqli_query($db,"select * from bruser where active='Y' and level<=5 and utype!='admin' order by brcode ,level desc,username")or die(mysqli_error($db));

}

   if($pstvl=='Level')
     { 
$result=mysqli_query($db,"select * from bruser where active='Y' and level<=5 and utype!='admin' order by level desc,username")or die(mysqli_error($db));


     }


?>
<table border=0  cellspacing=2 cellpadding=5>
<th>No.<th>User Name <th>Level <th>Branch <th>Full control <th>Branch Clearing<th>Back dated entries<th> Edit<th>Plantcode
<th>Type 
<?
$i=1;
while($row=mysqli_fetch_array($result))
{
    if($row[2]=='5')
    {
     $fc="YES" ;  
     $bc="FULL ACCESS";
     $be="FULL ACCESS";
     $ed="FULL ACCESS";
    }
    elseif ($row[2]=='4')
    {
      $fc="NO"  ;  
      $bc="7 DAYS";
      $be="7 days";
     $ed="3 days";
    }
    elseif ($row[2]=='3')
    {
      $fc="NO"  ;  
      $bc="7 DAYS";
      $be="7 days";
     $ed="No Edit";  
    }
    else
    {
      $fc="NO"  ;  
      $bc="NO";
      $be="NO";
     $ed="NO";  
    }
    
    $brname=getbrname($row[brcode]);
 print "\n<form action='$PHP_SELF' method='POST'> <input type=hidden name='code' value='$row[sno]'>";
 print "\n<tr bgcolor='c1d7bf' onMouseOver=bgColor='Pink'; onMouseOut=bgColor='c1d7bf'; >".
"<td>".$i++."</td><td>$row[1]</td><td align=center>$row[2]</td><td>$brname</td><td>$fc</td>".
"<td>$bc</td><td>$be</td><td>$ed</td>";
print "<td>$row[brcode]</td><td>$row[utype]</td>";
 print " </tr></form>";
}


}
?>

<form action='<?print $PHP_SELF?>' name='f1' method='post'>
<table>
<tr><td bgcolor='steelblue' colspan=2><center><b><font color=white>User Level Report</td></tr>
<!--
<tr><td>Date From </td><td>dd<input type=text name='d' size=2 value='<?print date("d");?>'>
			mm<input type=text name='m' size=2 value='<?print date("m");?>'>
			yy<input type=text name='y' size=4 value='<?print date("Y");?>'>
</td></tr>
<tr><td>Date To </td><td>dd<input type=text name='d1' size=2 value='<?print date("d");?>'>
			mm<input type=text name='m1' size=2 value='<?print date("m");?>'>
			yy<input type=text name='y1' size=4 value='<?print date("Y");?>'>
</td></tr>
-->
<tr><td>Sort BY</td><td><select name='pstvl'>
   <option value='Level'>Level</option> 
   <option value='Plant'>Plant</option> 


</select></td></tr>
<th colspan=2><INPUT TYPE=SUBMIT VALUE='SHOW' name='show'></td></tr>
</table>
</form>
<script>
function edfun(x,y)
{
 if(confirm('Do you want to edit P.O. No.'+x+' ?'))
  document.location='edpur.php?purno='+x+'&ttype='+y;
}
</script>


