<?php
	include'connection.php';
	$uid=$_GET['uid'];
	$DiffAmount=$_GET['diff'];
	$Date=$_GET['date'];
	
	date_default_timezone_set("asia/Kolkata");
	$date= Date("Y-m-d");
	$time=Date("h:i:s A");
	
	$query1="select * from wallet where Userid='$uid' order by Id desc";
	$result1=mysqli_query($con,$query1);
	$data1=mysqli_fetch_array($result1);
	$oldbal=$data1['Balance'];
	$newbal=$oldbal-$DiffAmount;
	
	$query2="insert into wallet(Userid,Openingbalance,Balance,Date,Time,Transactiontype)
	values('$uid','$oldbal','$newbal','$date','$time','Reverse_Audit_Differances($DiffAmount)_for_$Date')";
	
	if(mysqli_query($con,$query2))
	{
	    $query9="update retailer set Balance='$newbal' where Userid='$uid'";
	    mysqli_query($con,$query9);
							
		header('location:AccountReportsByUser.php');
	}

?>