<?php
/*
* date last modified 10-14-2018
* HTML Files - add_coupon.html.php
* Mysql Tables - tbl_discount_coupon
*/
require_once('includes/functions.php');
$debug = true;

if(isset($_REQUEST['user_id']) && $_REQUEST['user_id']!=''){
	$userId = trim($_REQUEST['user_id']);

// add new app
if(isset($_POST['add'])) {
	
	if(isset($_REQUEST['amount']) && $_REQUEST['amount']!=''){
		$amount = trim($_REQUEST['amount']);
		if(is_numeric($amount) && $amount>0){
			if($amount>200000){
				$error = 'Sorry, you can add a maximum of 100000 in a single submit.';
			}
		} else {
			$error = 'Enter a valid amount';
		}
	} else {
		$error = 'Enter Amount to credit';
	}
	


	if(empty($error)) {						
		
		$curDate = date('Y-m-d H:i:s');
		$insert = "INSERT INTO tbl_user_payments (`user_id`, `amount`, `type`, `payment_method`, payment_status, `added_date`) values 
		('".$userId."', '".$amount."', 'Deposit', 'Admin', 'Success', '".$curDate."')";
		
		$execInsert = mysqli_query($con, $insert);				
		if($execInsert) {
			$success = 'Credit Added Successfully';
			/*
			header('Location:index.php?page=manage_coupons&success='.$success);
			exit;*/
		?>
		<script>
			window.location='index.php?page=user_deposits&success=<?php echo($success); ?>';
		</script>
	<?php
		}				
	} else {
		//$error = "You are not allowed to add business under a static page menu."; 
	}
}

} else {
	header('Location:index.php?page=manage_users');
	exit;
}



?>