<?php  
	require_once('lib/functions.php');
	$db = new db_functions();
	
	require_once('date.php');
?>
<?php
	
	$agent_id	=	"";
	
	if(isset($_GET['agent_id']))
	{
		$agent_id	=	$_GET['agent_id'];
		$_SESSION['agent_id']	=	$agent_id;
	}
	elseif(isset($_SESSION['agent_id']))
	{
		$agent_id	=	$_SESSION['agent_id'];
	}
	
	$success_msg = 0;
	
	if(isset($_POST['submit']))
	{
		$agent_name	=	$_POST['agent_name'];
		$address	=	$_POST['address'];
		$mobile_no	=	$_POST['mobile_no'];
		$commission	=	$_POST['commission'];
		$agent_user_id	=	$_POST['user_id'];
		$password	=	$_POST['password'];
		
		
		
			if($db->update_new_vasuli_user($agent_name,$address,$mobile_no,$commission,$agent_user_id,$password,$agent_id))
			{
				$success_msg = 1;
			}
		
		else
		{
			$success_msg = 2;
		}	
	}
	
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<title><?php echo $project_title; ?></title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0"/>
	<link rel="stylesheet" href="/js/bootstrap.min.css">
	<link rel="stylesheet" src="text/css" href="css/style.css">
	<style>
	input 
	{ 
		width: 200px ; 
		border: 1px solid #000; 
		padding: 5px; 
	}
	.container2
	{
		text-align: left;
	}
	</style>
</head>
<body>

<div class="header1"><label style="font-size:12px;">|| श्री बालाजी प्रसन्न ||</label></div>

<?php
	if($success_msg==1)
	{
?>
<div class="alert alert-success" style="margin:15px;">
  <strong>Success!</strong> Agent Data Updated Successfully
</div>
<?php		
	}
	else if($success_msg==2)
	{
?>
<div class="alert alert-danger" style="margin:15px;">
  <strong>Failed!</strong> data not updated.
</div>
<?php		
	}
?>

<?php
	$res_id				=	"";
	$agent_name			=	"";
	$address			=	"";
	$mobile_no			=	"";
	$commission			=	"";
	$oc_rate_chillar	=	"";
	$oc_rate_thok		=	"";
	$b_rate_chillar		=	"";
	$b_rate_thok		=	"";
	$p_rate_chillar		=	"";
	$p_rate_thok		=	"";
	$metro_rate_chillar	=	"";
	$metro_rate_thok	=	"";
	$parel_rate_chillar	=	"";
	$parel_rate_thok	=	"";
	$user_id			=	"";
	$password			=	"";
	$date				=	"";
	$time				=	"";
		
	$record	=	$db->get_vasuli_user_data_from_id($agent_id);
	
	if(!empty($record))
	{
		$res_id				=	$record[0];
		$agent_name			=	$record[1];
		$address			=	$record[2];
		$mobile_no			=	$record[3];
		
		$res_agent_user_id	=	$record[5];
		$password			=	$record[6];
		$date				=	$record[7];
		$time				=	$record[8];
		
	}	
?>
<div class="container2  box-draw">
  <div style="font-weight:bold; font-size:22px; margin-top:20px; margin-bottom:10px; text-align:center;">नवीन एजन्ट</div>
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <div class="form-group col-sm-12 col-lg-12">
      <label for="name">नाव </label>
      <input type="text" class="form-control" name="agent_name" placeholder="नाव " required value="<?php echo $agent_name; ?>" />
    </div>
	<div class="form-group col-sm-12 col-lg-12">
      <label for="adr">पत्ता </label>
      <input type="text" class="form-control" name="address" placeholder="पत्ता " required value="<?php echo $address; ?>" />
    </div>
    <div class="form-group col-xs-6 col-sm-6 col-lg-12" style="width:48%; margin-top:15px;">
      <label for="mobile">मोबाईल नंबर </label>
      <input type="number" class="form-control" name="mobile_no" placeholder="मोबाईल नंबर " required value="<?php echo $mobile_no; ?>" />
    </div>
	
	<div class="form-group col-xs-6 col-sm-6 col-lg-12" style="width:48%; margin-top:15px;">
      <label for="commission">युजर  नेम</label>
      <input type="text" class="form-control" name="user_id" placeholder="युजर  नेम" required value="<?php echo $res_agent_user_id; ?>" />
    </div>
	<div class="form-group col-xs-6 col-sm-6 col-lg-12" style="width:48%; margin-top:15px;">
      <label for="commission">पासवर्ड</label>
      <input type="text" class="form-control" name="password" placeholder="पासवर्ड" required value="<?php echo $password; ?>" />
    </div>
	
	
	
    <center>
		<input type="submit" name="submit" value="जतन करा " class="btn btn-primary btn-lg btn-block button"  style="margin-top:6px; padding:14px; font-size:17px; width:48%;" />
	</center> 
	
	<br /><br />
	
  </form>
</div>
</body>
</html>
 