<?

ob_start();

session_start();

include("include/db.inc.php");

include("include/bit_functions.inc.php");

$db1=new db;

$db1->open();

mysql_query("SET NAMES 'utf8'");$currency_symbol_new=symbol_currency();



   $uid=$_SESSION['uid'];



   $sql_qry=mysql_query("select total_bid,total_price from t123go_bidpackage where pkgid=(select package_id from t123go_memberpack where id='".$_GET['orderid']."')");

   $mypkg=mysql_fetch_array($sql_qry);

   $order_id=base64_encode($_GET['orderid']);

   $package_name=$mypkg['total_bid']." Bids";

   $paypal_pay = mysql_fetch_array(mysql_query("select paypal_pay_id from admin where type='superadmin'"));

   $paypal_pay_id = $paypal_pay['paypal_pay_id'];



	if($_REQUEST['disc_code']!='')

	{

	 $disc_code=$_REQUEST['disc_code'];

	 $rs=mysql_query("select discount from discount_mail where code='".$disc_code."' and uid='".$uid."' and status='0'");

	 if (mysql_num_rows($rs)>0)

	    {

	       $dis_row=mysql_fetch_array($rs);

 	       $disc_price=($mypkg['total_price']) - $dis_row['discount'];

	       $total=$disc_price;

	       mysql_query("update discount_mail set status='1' where uid='$uid' and status='0'  and code='".$disc_code."'");

		}   

     else

	    {

		$sql1="select m.id,v.amount from t123go_memvoucher m inner join t123go_voucher v on m.voucher_id=v.vid where v.voucher_code='".$disc_code."' and m.user_id='".$uid."' and m.status='0' and date(v.start_to)<=date(now()) and date(v.valid_to)>=date(now())";

		$rs1=mysql_query($sql1);

		if (mysql_num_rows($rs1)>0)

	    {

	       $dis_row=mysql_fetch_array($rs1);

 	       $disc_price=($mypkg['total_price']) - $dis_row['amount'];

	        $total=$disc_price;

		   

	      mysql_query("update t123go_memvoucher set status='1' where  id='".$dis_row['id']."'");

		}

		else

		 {

		 $total=$mypkg['total_price'];

		 }  

		}

	 }else

	 {

	  $total=$mypkg['total_price'];

	  }



?>

<html>

<head>

<base href="<?=_BASEURL_?>/" />

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>

<body>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="form1">

     <input type="hidden" name="cmd" value="_xclick">

     <input type="hidden" name="business" value="<?=$paypal_pay_id;?>">

     <input type="hidden" name="item_name" value="<?=$package_name?>">

     <input type="hidden" name="item_number" value="<?=$package_name?>">

     <input type="hidden" name="notify_return" value="<?=_BASEURL_?>/notify.php?orderid=<?=$order_id?>">

     <input type="hidden" name="return" value="<?=_BASEURL_?>/success.php?orderid=<?=$order_id?>">

     <input type="hidden" name="cancel_return" value="<?=_BASEURL_?>/cancel.php?orderid=<?=$order_id?>&disc_code=<?=$disc_code?>">

     <input type="hidden" name="amount" value="<?=$total;?>">

     <input type="hidden" name="no_note" value="1">

     <input type="hidden" name="rm" value="2">

      <input type="hidden" name="lc" value="FR">

     <input type="hidden" name="currency_code" value="<?=get_currency_code();?>">

</form>

<script language="JavaScript"> document.form1.submit()</script>

</body>

</html>