<?php
session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}
	
	
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
include("mylibrary.php");
	$umid= ($_POST['umid']);
	$contactname=checkvalidstring ($_POST['contactname']);
	
	
	$cmiddlename=checkvalidstring ($_POST['cmiddlename']);
	
	
	$csurname=checkvalidstring ($_POST['csurname']);
	
	
		$contactnumber=checkvalidstring ($_POST['contactnumber']);
	
	
	
	$cmobilenumber=checkvalidstring ($_POST['cmobilenumber']);
	
	$contactemail=checkvalidstring ($_POST['contactemail']);
	
	$caltenateemail=checkvalidstring ($_POST['caltenateemail']);
	
	
	
	
	
	$caddress1=checkvalidstring ($_POST['caddress1']);
	
	
	$caddress2=checkvalidstring ($_POST['caddress2']);
	
	
	$ccountry=checkvalidstring ($_POST['ccountry']);
	
	$cpostalcode=checkvalidstring ($_POST['cpostalcode']);
	
	
	$cmsgappname=checkvalidstring ($_POST['cmsgappname']);
	
	
	$cmsgappid=$_POST['cmsgappid'];
	
	
	$cvideoappname=checkvalidstring ($_POST['cvideoappname']);
	
	
	$cvideoappid=$_POST['cvideoappid'];
	
	
	
	$cstate=checkvalidstring ($_POST['cstate']);
	
	
	$ccity=$_POST['ccity'];
	
	
	
	
	
	
	
	$ustatus="Approved";

	$ucode=$_POST['ucode'];
	
	
	
	$uwebsite=checkvalidstring($_POST['uwebsite']);
	$umobile=checkvalidstring($_POST['umobile']);
	$upass=checkvalidstring($_POST['upass']);
	$ubusinessname=checkvalidstring($_POST['ubusinessname']);
	
	$ubussinessyear=checkvalidstring($_POST['ubussinessyear']);
	$ubussinessregistrationnum=checkvalidstring($_POST['ubussinessregistrationnum']);
	$upannumber=checkvalidstring($_POST['upannumber']);
	$uagreementnumber=checkvalidstring($_POST['uagreementnumber']);
	
	
	$ubank=checkvalidstring($_POST['ubank']);
	$ubranch=checkvalidstring($_POST['ubranch']);
	$customermid=checkvalidstring($_POST['customermid']);
	$uaccountnumber=checkvalidstring($_POST['uaccountnumber']);
	$uifsccode=checkvalidstring($_POST['uifsccode']);
	$umicrcode=checkvalidstring($_POST['umicrcode']);
	$uaccountdetails=checkvalidstring($_POST['uaccountdetails']);
	$ugst=checkvalidstring($_POST['ugst']);
	
	
	
	$uoqneraadharnumber=checkvalidstring($_POST['uoqneraadharnumber']);
	
	
	
	$couid=0;
	
	//$rolemid=$_POST['rolemid'];
	//$dashboardurl=$_POST['dashboardurl'];
	//$udate1=implode('-', array_reverse(explode('-', $_POST['udate1'])));
	//$udate2=implode('-', array_reverse(explode('-', $_POST['udate2'])));
	
	$tt1 ='';
	if(empty($_FILES['uimage']['name']) == false  )
	{
		$uimage = date("YmdHis").$_FILES['uimage']['name'];
		$path = "docs/";
		move_uploaded_file( $_FILES['uimage']['tmp_name'], $path ."/". $uimage );
		$tt1 = ",uimage='$uimage'";
	
	}
	
	
	 $eve = "update res_user_master set ustatus='$ustatus',ucode='$ucode',uwebsite='$uwebsite',umobile='$umobile',upass='$upass',ubusinessname='$ubusinessname',ubussinessyear='$ubussinessyear',ubussinessregistrationnum='$ubussinessregistrationnum',upannumber='$upannumber',uagreementnumber='$uagreementnumber',ubank='$ubank',ubranch='$ubranch',customermid='$customermid',uaccountnumber='$uaccountnumber',uifsccode='$uifsccode',umicrcode='$umicrcode',uaccountdetails='$uaccountdetails',ugst='$ugst',uoqneraadharnumber='$uoqneraadharnumber' $tt1 and umid=$umid   ";
			
	
	
	if ($conn->query($eve) === TRUE)
	{
			 $eve2 = "update res_contact_master set contactname='$contactname', contactemail='$contactemail',contactnumber='$contactnumber',cmobilenumber='$cmobilenumber',contactdepartmnet='Agent',caltenateemail='$caltenateemail',caddress1='$caddress1',caddress2='$caddress2',ccountry='$ccountry',cstate='$cstate',ccity='$ccity',cpostalcode='$cpostalcode',cmiddlename='$cmiddlename',csurname='$csurname',cmsgappname='$cmsgappname',cmsgappid='$cmsgappid',cvideoappname='$cvideoappname',cvideoappid='$cvideoappid' where clinktype='Agent' and  clinkid='$umid'";
			$re2 = mysqli_query($conn, $eve2);
		$_SESSION['msg'] = "Record has been updated successfully";
		header('Location: agent.php');
			
	}
	
	
	
?>