<?php session_start();  //Developed by ITechScripts
   require 'include/announcements.php'; // ITECHBIDS Configuration File
require 'include/itechbids.php'; // Server compatibility Patch

   require 'include/calculate.php';
   require 'payments/api.php';

$default_currency="select * from genaralsettings where set_id=55";
$default_res=mysql_query($default_currency);
$default_row=mysql_fetch_array($default_res);
$default_cur=$default_row[set_value];
$datecheck=date("Y-m-d H:i:s");
$default_currency="select * from genaralsettings where set_id=58";
$default_res=mysql_query($default_currency);
$default_row=mysql_fetch_array($default_res);
$bid_cost=$default_row[set_value];

$default_currency="select * from genaralsettings where set_id=56";
$default_res=mysql_query($default_currency);
$default_row=mysql_fetch_array($default_res);
$default_cur_code=$default_row[set_value]; 

   $productid=$_POST[productid];
   $recycle=$_POST[recycle];

   $paymentid=$_POST[paymentid];
   $payid=$paymentid; 
   
$recycle=$_POST[recycle];
   $sql_user1="select * from auction_details where productid=$productid";
   $res_user1=mysql_query($sql_user1);
   $row=mysql_fetch_array($res_user1);
   $seller_id=$row['user_id'];  
   $postformat=$row['selling_method']; 
   $quick_buy_price=$row['quick_buy_price'];
$or_price=$row['or_price'];
if(($recycle=="yes")&&($postformat=="11"))
{
   $del_query="update auction_details set status='Inactive', expire_date='$datecheck' where productid=$productid";
   mysql_query($del_query);

}
function diplay_payments()
	{
		$gate_select_query="select * from payment_gateway where status='yes'";
		$gate_select_result=mysql_query($gate_select_query);
?>
	<table border=0 align=center cellpadding=5 cellspacing=2 width=100%><tr>
	<td align="center" width=100%><select name=paymentid>

<?
		$length=1;
		while($gate_select_row=mysql_fetch_array($gate_select_result)) {
		$gateway_id=$gate_select_row['gateway_id'];
            $payment_gateway=$gate_select_row['payment_gateway'];
?>
	<option value="<?=$gateway_id?>"><?=$payment_gateway?></option>



<?
		$length+=1;
		}
?>
</select></td>
	</tr>
	</table>
<?
}
?>
<?


   $_SESSION[seller_id]=$seller_id;

   $query="select * from member_details where user_id =".$row[user_id];
   $table=mysql_query($query);
   if($seller_row=mysql_fetch_array($table))
   {
   $seller_name=$seller_row['user_name'];  
   $seller_email=$seller_row['email']; 
   }
   if($postformat=="11")
{
   $bid_sql="select * from site_bids where productid= $productid and user_id=$_SESSION[userid] order by bidding_amount asc";
   
}
   if($postformat!="11")
{
   $bid_sql="select * from site_bids where productid= $productid and user_id=$_SESSION[userid] order by bidding_amount desc";
   
}
$bid_res=mysql_query($bid_sql);
   $bid_det=mysql_fetch_array($bid_res);
   $totalprice=($bid_det[quantity] * $bid_det[bidding_amount]);
   $_SESSION[totalprice]=$totalprice;
	$_SESSION['productid']=$productid;
	$buy_query="select * from member_details where user_id =".$_SESSION[userid];
    $buy_res=mysql_query($buy_query);
    $buyer_row=mysql_fetch_array($buy_res);
	
	$admin="select * from genaralsettings where set_id=1"; //sitename -> id=1
	$admin_res=mysql_query($admin);
	$admin_rec=mysql_fetch_array($admin_res);
	
	$yoursite=$admin_rec[set_value];
	$bidpricing= $bid_det[bidding_amount] * $bid_det[quantity];
	$shipping=$row[shipping_cost];
	
if($postformat=="3")
{
$bidpricing=0;
}
if(($postformat=="5")||($postformat=="10"))
{
$bidpricing=$quick_buy_price;
}


if(($recycle=="yes")&&($postformat!="11")){
$userid=$_SESSION['user_id'];
   $bid_sql_r="select productid from site_bids where productid='$productid' and user_id=".$userid;
   $bid_res_r=mysql_query($bid_sql_r);
   $bid_det_r=mysql_num_rows($bid_res_r);
$bid_rebate=$bid_det_r*$bid_cost;
   $totalprice=($or_price - $bid_rebate);
$bidpricing = "$totalprice";
}


require 'payments/gateways.php';
$pricing=$bidpricing+$tax+$shipping;
$asd1 = rand(100, 1000);
$asd2 = date(gis);
$asd=$asd1+$asd2;
$userid=$_SESSION['user_id'];
$tr_id = ''.$userid.''.$asd.'##buy_pay##'.$userid.'##'.$productid.'##'.$recycle; 
require'themes/reviewdetails.tpl';
  ?>
  <tr><td>
  <? 
   require 'templates/'.$tfold.'/footer.php';					
  ?>
  </td></tr>
 </table>
</body>
</html>