<?
	include("config/connect.php");
	include("session.php");
	include("functions.php");
	$uid = $_SESSION["userid"];
	if(!$_GET['pgno'])
	{
		$PageNo = 1;
	}
	else
	{
		$PageNo = $_GET['pgno'];
	}
	/*
	$qryselauc = "select *,p.".$lng_prefix."name as name,".$lng_prefix."short_desc as short_desc from bid_account ba left join auction a on ba.auction_id=a.auctionID left join products p on ba.product_id=p.productID left join auc_due_table adt on a.auctionID=adt.auction_id left join `won_auctions` wa on a.`auctionID`=wa.`auction_id` where a.auc_status='3' and adt.auc_due_time=0 and ba.user_id=$uid and ba.`user_id`!=wa.`userid`  group by ba.auction_id order by auc_due_time";
	*/
	$now=time();
	$qryselauc = "
	select * from (
select b.`auctionID`,c.`cn_name` as name ,c.cn_short_desc as short_desc,c.`picture1`
  from bid_account a,
       auction b,
       products c,
       auc_due_table d,
       won_auctions e
 where a.`auction_id`=b.`auctionID`
   and a.`product_id`=c.`productID`
   and b.`auctionID`=d.`auction_id`
   and b.`auctionID`=e.`auction_id`
   and b.`auc_status`='3'
   and d.`auc_due_time`<$now
   and a.`user_id`=$uid
   and a.`user_id`!=e.`userid`
group by a.auction_id 
order by auc_due_time ) pp
where pp.auctionID not in (

select a.`auction_id` 
  from bid_account a,
       auction b,
       products c,
       auc_due_table d,
       won_auctions e,
       `shops_orders` f
 where a.`auction_id`=b.`auctionID`
   and a.`product_id`=c.`productID`
   and b.`auctionID`=d.`auction_id`
   and b.`auctionID`=e.`auction_id`
   and b.`auc_status`='3'
   and d.`auc_due_time`<$now
   and a.`user_id`=$uid
   and a.`user_id`!=e.`userid`
   and b.`auctionID`=f.`aid`
   and a.`user_id`=f.`userid`
   and f.`state`=1
group by a.auction_id 
order by auc_due_time)";
  //echo $qryselauc;
	$resselauc = mysql_query($qryselauc);
	$totalauc = mysql_num_rows($resselauc);
	$totalpage=ceil($totalauc/$PRODUCTSPERPAGE_MYACCOUNT);

	if($totalpage>=1)
	{
	$startrow=$PRODUCTSPERPAGE_MYACCOUNT*($PageNo-1);
	$qryselauc.=" LIMIT $startrow,$PRODUCTSPERPAGE_MYACCOUNT";
	//echo $sql;
	$resselauc=mysql_query($qryselauc);
	$totalauc=mysql_num_rows($resselauc);
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$lng_characset;?>" />
<title>我的拍点</title>
<link href="css/style_youbid.css" rel="stylesheet" type="text/css" />

</head>


<body onload="OnloadPage();">
<div id="main_div">
<?
	include("d1.php");
?>
		<div id="middle_div">
			<? include("leftside.php"); ?>
			<div class="inner-container">
				<div class="titlebar">
					<div class="leftbar"></div>
					<div class="middlebar"><div class="page_title_font">您可以马上购买的商品</div></div>
					<div class="rightbar"></div>
				</div>
				<div class="bodypart">	
					<div style="height: 15px;">&nbsp;</div>
					<?
					if($totalauc>0)
					{
					?>
					<?
						$counter = 1;
						while($obj = mysql_fetch_array($resselauc))
						{
							if($counter==1)
							{
								$arr = $obj["auctionID"];
								$prr = $obj["auc_due_price"];
							}
							else
							{
								$arr .= ",".$obj["auctionID"];
								$prr .= ",".$obj["auc_due_price"];
							}
					 ?>	
					 <? if($counter==1){ ?>
						<div class="strip">
							<div class="imagetext"><?=$lng_image;?></div>
							<div class="descriptiontext"><?=$lng_description;?></div>
							<div class="pricetext">获胜者</div>
							<div class="biddertext" style="width: 105px; text-align: right;"></div>
							
						</div>
						<div style="height: 15px;">&nbsp;</div>
					<? } ?>
					  <div class="auction-item" style="display: none" title="<?=$obj["auctionID"];?>" id="auction_<?=$obj["auctionID"];?>"></div>
						<div class="even-row">
							<div class="evenproductimage"><a href="auction_<?=str_replace(" ","_",strtolower(stripslashes($obj["name"])));?>_<?=$obj["auctionID"];?>.html"><img src="uploads/products/thumbs_big/thumbbig_<?=$obj["picture1"];?>" border="0"></a></div>
							<div class="evenproductdesc"><div class="auction_decription"><a href="auction_<?=str_replace(" ","_",strtolower(stripslashes($obj["name"])));?>_<?=$obj["auctionID"];?>.html" class="black_link"><?=stripslashes($obj["name"]);?></a><br /><br /><?=stripslashes(choose_short_desc($obj["short_desc"],160));?><a href="auction_<?=str_replace(" ","_",strtolower(stripslashes($obj["name"])));?>_<?=$obj["auctionID"];?>.html" class="black_link"><?=$lng_linkmore;?></a></div></div>
							<div class="evenproductprice">
								<span class="body_inner_box_price">
									<span style="font-size:15px; font-weight: bold;" id="currencysymbol_<?=$obj["auctionID"]?>"></span><span style="font-size:15px; font-weight: bold;" id="price_index_page_<?=$obj["auctionID"];?>">---</span><br />
									<div style="padding-top: 5px;" class="bidderfont">
										<span id="product_bidder_<?=$obj["auctionID"];?>"></span>
									</div>
								</span>
							</div>
							<div class="evenproductcountdown">
								<img src="<?=$lng_imagepath;?>buynow_btn.png" border="0"  alt="您可以市场价减去竞拍费用购买本商品" onclick="javascript: window.location.href='buynow.html?aucid=<?=$obj["auctionID"];?>'" style="cursor: pointer"/>
							</div>
						</div>
					
					<?
							$counter++;	
						}
					?>
					<div style="height: 10px;"></div>
					<div class="strip">
						<div style="padding-top: 2px;">
					<?
					if($PageNo>1)
					{
					  $PrevPageNo = $PageNo-1;
					?>
						  <A class="alink" href="myauctions_<?=$PrevPageNo; ?>.html">&lt; <?=$lng_previouspage;?></A>
					<?
						if($totalpage>2 && $totalpage!=$PageNo)
						{
					 ?>
						<span class="paging">&nbsp;|</span>
					 <?
						}
					  }
				     ?>&nbsp;
				     <?php
			 		  if($PageNo<$totalpage)
					  {
						 $NextPageNo = 	$PageNo + 1;
					  ?>
						  <A class="alink" id="next" href="myauctions_<?=$NextPageNo;?>.html"><?=$lng_nextpage;?> &gt;</A>
					  <?
					   }
					  ?>
					     </div>
					</div>	
					<?
					}
					else
					{
					?>		
					<div>&nbsp;</div>
					<div class="noauction_message" align="center">您现在没有可以马上购买的商品</div>
					<div>&nbsp;</div>
					<?
					}
					?>
				</div>
				<div class="bottomline">
					<div class="leftsidecorner"></div>
					<div class="middlecorner"></div>
					<div class="rightsidecorner"></div>
				</div>
			</div>
		</div>
<?
	include("footer2.php");
?>		
</div>

</body>
</html>
