<?php
 	session_start(); 

	if(!isset($_SESSION['linkarisesuloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	if($_SESSION['linkariseutype']!='Superuser'){
			header('Location: index.php');
		return;
	}
	date_default_timezone_set("Asia/Singapore");
	$cdatetime= date('Y-m-d H:i:s');
	$cdate= date('Y-m-d');
				
	
	
	include("connect.php");

	$cmpname=$_POST['cmpname'];
	$brmid=$_POST['brmid'];
	$cmptype=$_POST['cmptype'];
	$cpname=$_POST['cpname'];
	$cpmobile=$_POST['cpmobile'];
	$cmpaddress=$_POST['cmpaddress'];
	$username=$_POST['username'];
	$usermobile=$_POST['usermobile'];
	$userdesignation=$_POST['userdesignation'];
	$userloginid=$_POST['userloginid'];
	$usersecurepasword=md5($_POST['userpassword']);
	$companyprefix=$_POST['companyprefix'];
	
	$eve = "update res_company_master set companyname='$cmpname',companyaddress='$cmpaddress',companycontactperson='$cpname',companytype='$cmptype',companycontectno='$cpmobile',companyprefix='$companyprefix',updatedon='$cdatetime' where companymid=$brmid";	
	
	if ($conn->query($eve) === TRUE)
	{
		
			 $eve2 = "update res_user_master set username='$username',usermobile='$usermobile',userloginid='$userloginid',usersecurepasword='$usersecurepasword' where userdesignation='Admin' and companymid=$brmid";	
			if ($conn->query($eve2) === TRUE)
			{	
	
			$_SESSION['msg'] = "Record has been updated successfully";
			}
			else{
				$_SESSION['msg1'] = "Error!";
			}
	}
	else{
		$_SESSION['msg1'] = "Error!";
	}
		header('Location: businessregister.php');
			
?>