<?php
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";


	$check_coupon_valid = "SELECT ngift_coupon_amount
							FROM ".$tableprefix."giftcoupon_master
							WHERE vgift_coupon_code = ".GetSQLValueString($_GET['coupon_code'],"text");
						    
	$result_coupon_valid = mysql_query($check_coupon_valid) or die(mysql_error());		
	
	// function call to check the gift certificate used belongs to the correct seller
	
	$seller_check = checkGiftCertificateSeller($_GET['coupon_code']);
	
	
	if(mysql_num_rows($result_coupon_valid) == 0)
	{
	
		echo 1;
		
	}
	else
	{
	
		$coupon_row = mysql_fetch_assoc($result_coupon_valid);
		/*$gift_dollar_amount = ($coupon_row['ngift_coupon_amount']/$coupon_row['nexchange_price']);
		
		$select_currency_type = "SELECT nexchange_price FROM ".$tableprefix."currency_master WHERE vactive = 'Y'";
		$result_currency_type = mysql_query($select_currency_type) or die(mysql_error());
		$currency_row = mysql_fetch_assoc($result_currency_type);
		
		$final_gift_amount = $gift_dollar_amount * $currency_row['nexchange_price'];*/  		
	
		if($coupon_row['ngift_coupon_amount'] < $_GET['coupon_amount'])
		{
			echo 2;
		}
		elseif($seller_check == 1)
		{
			echo 3;
		}
		else
		{
			echo 4;
		}
	
	}	
?>