<?php
	ob_start();
	session_start();
?>
<?php
include("config.php");
if(!isset($_SESSION["adminname"]))	{
	header("Location: index.php");
}
?>
<html>
<head><title>BM BIO ENERGY</title>
<style type="text/css">
.view
{
padding: 2px;
font-weight: bold;
width: 11%;
background: #5CB85C none repeat scroll 0% 0%;
font-size: 24px;
color: #FFF;
text-decoration: none;
border: 1px solid #FFF;
text-align: center;
border-radius: 4px;
height: 27px;
position: absolute;
right: 416px;
top: 256px;
}
.pdf
{
padding: 2px;
font-weight: bold;
width: 11%;
background: #5CB85C none repeat scroll 0% 0%;
font-size: 24px;
color: #FFF;
text-decoration: none;
border: 1px solid #FFF;
text-align: center;
border-radius: 4px;
height: 27px;
position: absolute;
right: 350px;
top: 566px;
}
label{ 
font-size: 25px; 
width:29%;
float: left;
} 
.box1
{
margin-top: -36px;
width:100%;

}

.box2
{
width: 33%;
float: left;
margin-top: 30px;
}
.box22
{
width: 67%;
float: left;
margin-top: -311px;
margin-left: 418px;
}
.box33
{
width: 26%;
float: right;
margin-top: -357px;
margin-right: 73px;
}
.box44
{
width: 60%;
float: left;
margin-top: -212px;
margin-left: 1061px;
}
.box3
{
width: 66%;
float: left;
font-size: 24px;
}
.seae
{
width: 7%;
float: left;
font-size: 18px;
font-weight: bold;
}
.box4
{
width: 85%;
float: left;
margin-top: 13px;
}
.don
{
width: 100%;
float: left;
}
.inpu
{ 
width: 100%;
border: 1px solid #000;
height: 35px;
font-size: 18px;
border-radius: 4px;
margin-top: 0px;
}

.inpu1
{ 
width: 100%;
}
table, tr, td {
border: 1px solid white;
border-collapse: collapse;
padding: 8px;
font-size: 19px;
}
table  input[type=text]
{
height: 33px;
border: 1px solid #000;
border-radius: 4px;
font-size: 15px;
padding: 9px;
}

table {
width: 100%;
}
.table
{
margin: 29px;
width: 90%;
font-size: 23px;
}
.fool
{
width: 60%;
float: left;
margin-left: 12%;
}
.thala 
{
width: 100%;
color: #FFF;
margin-top: 0px;
}
.bo
{
margin-top: 12px;
width: 99%;
margin-left: 23px;
}
.se
{
margin-top: 11px;
width: 38%;
}
.out
{
background-color: #5CB85C;
text-decoration: none;
width: 12%;
height: 28px;
float: right;
text-align: center;
color: #FFF;
border-radius: 4px;
border: 1px solid #FFF;
top: 0px !important;
position: absolute;
margin-left: 40px;
}
.voice
{
width: 20%;
height: 28px;
border-radius: 4px;
border: 1px solid black;
font-size: 18px;
}
.sub
{
font-weight: bold;
width: 11%;
background: #5CB85C none repeat scroll 0% 0%;
font-size: 24px;
color: #FFF;
text-decoration: none;
border: 1px solid #FFF;
text-align: center;
border-radius: 4px;
height: 33px;
position: absolute;
right: 574px;
top: 256px;
font-family: times new;

}
.ser
{
width: 100%;
}
</head>
</style>
<body style="background-color: rgb(0, 150, 136);">
<div class="thala">
<center><h1>BM BIO ENERGY</h1></center><h2 style="margin-left:85%; ">
<a class="out" href="logout.php">Logout</a></h2>
</div>
<?php
if(isset($_GET['id'])){
	$id=$_GET['id'];
	if(isset($_POST['submit'])){
		$password=$_POST['password'];
		$qry1=mysql_query("update user set password='$password' where id='$id'");
		if($qry1){
			header("Location: passchange.php");
		}
	}
	$qry2=mysql_query("select * from user where id='$id'");
	$rw=mysql_fetch_assoc($qry2);
	
?>

		<form method="post" enctype="multipart/form-data">
		<div class="box1">
			<div class="box2">
				<label>Username :</label>
				<div class="box3">
					<input type="text" placeholder="Username" class="inpu" name="username" id="username" value="<?=$rw['username'];?>" readonly />
				</div>
			</div>
			<div class="box2">
				<label>Old Password:</label>
				<div class="box3">
					<input type="text" placeholder="Old Password" class="inpu" name="opassword" id="opassword" value="<?=$rw['password'];?>" readonly />
				</div>
			</div>
			<div class="box2">
				<label>New Password:</label>
				<div class="box3">
					<input type="text" placeholder="Enter New Password" class="inpu" name="password" id="password" />
				</div>
			</div>
			
		</div>
		<div style="clear:both;"></div>
			<div class="fool"><center><input type="submit" name="submit" id="submit" class="sub"  value="Submit"></center></div>
		</form>
	<?php }else{ ?>
		<table >
		<tr><td >Username</td><td>Password</td><td >Change Password</td></tr>
		<?php 
		$result=mysql_query("select * from user order by id"); 
		$i=1;
		while($row=mysql_fetch_array($result))
		{
			$id=$row['id'];
			echo '<tr>';
			echo '<td >'.$row['username'].'</td>';
			echo '<td >'.$row['password'].'</td>';
			echo '<td><a href="passchange.php?id='.$id.'" title="Collection Entry"><img style="width: 5%;" src="img/edit.png"><img></a></td></tr>';
			$i++;
		}
		?>
		</table>
	<?php } ?>
		<div class="fool"><center><a href="viewreport.php" class="view">Bill View</a></center></div>
</body>
</html>
<script>
function check(coll,pend){
	if(parseFloat(pend)<parseFloat(coll)){
		alert("Please enter the collection amount less then or equal to Outstanding amount")
		document.getElementById("collectionamount").value='';
	}
}
function fnamt(id){
var foo = document.getElementById(id);
foo.addEventListener('input', function (prev) {
    return function (evt) {
        if (!/^\d{0,6}(?:\.\d{0,2})?$/.test(this.value)) {
          this.value = prev;
        }
        else {
          prev = this.value;
        }
    };
}(foo.value), false);
}	
</script>