<?php
require ("../connection.php");
require ("../user.php");
$user=$_SESSION['user'];
$cur_date=date("Y-m-d h:i:s");
	$user_name=$_REQUEST['user'];
	$branch_id=$_REQUEST['branch'];
	
	$sql=mysqli_query($con,"select * from branch_mapping where user_id='$user_name'");
	 $row=count($sql);
	
	if($row >=1)
	{
		$update=mysqli_query($con,"update branch_mapping set status='1',to_date='$cur_date',modified_by='$user',modified_on='$cur_date' where user_id='$user_name'");
		
		$update1=mysqli_query($con,"insert into branch_mapping(branch_id,user_id,status,from_date,created_by,created_on)values('$branch_id','$user_name','0','$cur_date','$user','$cur_date')");
		
	}
	
	else
	{
		$insert=mysqli_query($con,"insert into branch_mapping(branch_id,user_id,status,from_date,created_by,created_on)values('$branch_id','$user_name','0','$cur_date','$user','$cur_date')");
		
	}
	
	

?>