<?php
session_start();

	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	$cmpmid=$_SESSION['linkarisecmpmid'];
	include("connect.php");
	
	$umid=(int)mysqli_real_escape_string($conn,$_GET['id']);
	
	
	$eve = "select * from res_user_master where  companymid=$cmpmid and usermid=".$umid;
	$re = mysqli_query($conn, $eve);
	if(mysqli_num_rows($re) > 0)
	{
		while($rt = mysqli_fetch_assoc($re))
		{
			if($rt['userstatus']=='Active')
			{
	
					 $eve3 = "update res_user_master set userstatus='Blocked' where companymid='$cmpmid' and usermid=".$umid;
					$re3 = mysqli_query($conn, $eve3);
					$_SESSION['msg'] = "User Status Changed";
			}
			else
			{
				 $eve3 = "update res_user_master set userstatus='Active' where companymid='$cmpmid' and usermid=".$umid;
					$re3 = mysqli_query($conn, $eve3);
					$_SESSION['msg'] = "User Status Changed";
			}
	}}
	
	header('Location: user.php');
?>