<?
	include("config/connect.php");
	include("session.php");
	include("functions.php");
	$uid = $_SESSION["userid"];


	if(!$_GET['pgno'])
	{
		$PageNo = 1;
	}
	else
	{
		$PageNo = $_GET['pgno'];
	}

	$qrysel = "select *,".$lng_prefix."credit_description as credit_description from bid_account ba left join bidpack b on ba.bidpack_id=b.id where user_id=$uid and ba.bid_flag='c' order by ba.id desc";
	$rssel = mysql_query($qrysel);
	$total = mysql_num_rows($rssel);
	$totalpage=ceil($total/$PRODUCTSPERPAGE_MYACCOUNT);

	if($totalpage>=1)
	{
	$startrow=$PRODUCTSPERPAGE_MYACCOUNT*($PageNo-1);
	$qrysel.=" LIMIT $startrow,$PRODUCTSPERPAGE_MYACCOUNT";
	//echo $sql;
	$rssel=mysql_query($qrysel);
	$total=mysql_num_rows($rssel);
	}
	
	if(!$_GET['pgNo'])
	{
		$PageNo1 = 1;
	}
	else
	{
		$PageNo1 = $_GET['pgNo'];
	}

	$qrysel1 = "select *,sum(ba.bid_count) as bidcount, a.auc_status as aucstatus,".$lng_prefix."short_desc as short_desc,".$lng_prefix."name as name from bid_account ba left join products p on ba.product_id=p.productID left join auction a on ba.auction_id=a.auctionID where user_id='$uid' and bidding_type!='m' and (ba.bid_flag='d' or ba.bid_flag='b') group by ba.auction_id order by ba.id desc";
	$rssel1 = mysql_query($qrysel1);
	$total1 = mysql_num_rows($rssel1);
	$totalpage1=ceil($total1/$PRODUCTSPERPAGE_MYACCOUNT);
	
	if($totalpage1>=1)
	{
	$startrow=$PRODUCTSPERPAGE_MYACCOUNT*($PageNo1-1);
	$qrysel1.=" LIMIT $startrow,$PRODUCTSPERPAGE_MYACCOUNT";
	//echo $sql;
	$rssel1=mysql_query($qrysel1);
	$total1=mysql_num_rows($rssel1);
	}
	
	if(!$_GET['pgNo1'])
	{
		$PageNo2 = 1;
	}
	else
	{
		$PageNo2 = $_GET['pgNo1'];
	}

	
	$qryselsms = "select *,sum(ba.bid_count) as totalsmsbidcount, a.auc_status as aucstatus,".$lng_prefix."short_desc as short_desc, ".$lng_prefix."name as name from bid_account ba left join products p on ba.product_id=p.productID left join auction a on ba.auction_id=a.auctionID where user_id='$uid' and ba.bidding_type='m' and bid_flag='d' group by ba.auction_id order by ba.id desc";
	$rsselsms = mysql_query($qryselsms);
	$totalsms = mysql_num_rows($rsselsms);
	$totalpagesms=ceil($totalsms/$PRODUCTSPERPAGE_MYACCOUNT);

	if($totalpagesms>=1)
	{
	$startrow=$PRODUCTSPERPAGE_MYACCOUNT*($PageNo2-1);
	$qryselsms.=" LIMIT $startrow,$PRODUCTSPERPAGE_MYACCOUNT";
	//echo $sql;
	$rsselsms=mysql_query($qryselsms);
	$totalsms=mysql_num_rows($rsselsms);
	}

?>
<!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><?=$AllPageTitle;?></title>
<link href="css/style_youbid.css" rel="stylesheet" type="text/css" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<link href="css/menu_ie.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script language="javascript" type="text/javascript" src="function.js"></script>
<script language="javascript" src="basic.js"></script>
<script language="javascript">
	function BidHistoryPlus(id,plus,minus)
	{
		document.getElementById(plus).style.display = 'none';
		document.getElementById(minus).style.display = 'block';
		document.getElementById(id).style.display = 'block';
	}	

	function BidHistoryMinus(id,plus,minus)
	{
		document.getElementById(plus).style.display = 'block';
		document.getElementById(minus).style.display = 'none';
		document.getElementById(id).style.display = 'none';
	}	
</script>
</head>


<body>
<div id="main_div">
<?
	include("d1.php");
?>
		<div id="middle_div">
			<? include("leftside.php"); ?>
			<?
				if($total!=0)
				{
			?>
			<div class="inner-container">
				<div class="titlebar">
					<div class="leftbar"></div>
					<div class="middlebar"><div class="page_title_font"><?=$lng_myauctionsavenue;?> - <?=$lng_purchasebids;?></div></div>
					<div class="rightbar"></div>
				</div>
				<div class="bodypart">	
					<div class="strip">
						<div class="purchasedate" align="center"><?=$lng_bidsdate;?></div>
						<div class="purchasedesc"><?=$lng_description;?></div>
						<div class="purchasebid"><?=$lng_bids;?></div>
					</div>
				<?
				$i = 1;
				while($obj = mysql_fetch_array($rssel))
				{
					$date = substr($obj["bidpack_buy_date"],0,10);
				?>
				<div <? if($i!=$total){ ?> style="height: 40px; border-bottom: 1px solid #cddce9; padding-top: 10px;" <? } else{ ?> style="height: 40px; padding-top: 10px;"  <? } ?>>
					<div class="purchasedate" align="center"><span class="normal_text"><b><?=arrangedate($date)."<br>".substr($obj["bidpack_buy_date"],11);?></b></span></div>
					<div class="purchasedesc"><span class="normal_text"><?=$obj["credit_description"];?></span></div>
					<div class="purchasebid">
					<?
						if($obj["bid_count"]>0)
						{
					?>
						<span class="greenfont"><b>+<?=$obj["bid_count"];?></b></span>
					<?
						}
						else
						{
					?>
						<span class="red-text-12-b"><?=$obj["bid_count"];?></span>
					<?
						}
					?>
				</div>
				</div>
				<div id="cleaner"></div>
				<?
					$i++;
				}
				?>
					<div class="strip">
						<div style="padding-top: 2px;">
					<?
					if($PageNo>1)
					{
					  $PrevPageNo = $PageNo-1;
					?>
						  <A class="alink" href="bid_history_<?=$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="bid_history_<?=$NextPageNo;?>.html"><?=$lng_nextpage;?> &gt;</A>
					  <?
					   }
					  ?>
					     </div>
					</div>	
				</div>
				<div class="bottomline">
					<div class="leftsidecorner"></div>
					<div class="middlecorner"></div>
					<div class="rightsidecorner"></div>
				</div>
			</div>
			<?
			}
			?>
		   <?
				if($total1!=0)
				{
		   ?>
			<div class="inner-container">
				<div class="titlebar">
					<div class="leftbar"></div>
					<div class="middlebar"><div class="page_title_font"><?=$lng_myauctionsavenue;?> - <?=$lng_historybids;?></div></div>
					<div class="rightbar"></div>
				</div>
				<div class="bodypart">	
						<div class="strip">
							<div class="watchimagetext"><?=$lng_image;?></div>
							<div class="watchdescriptiontext"><?=$lng_description;?></div>
							<div class="watchpricetext"><?=$lng_biddingstart;?></div>
							<div class="watchbiddertext"><?=$lng_biddingstatus;?></div>
							<div class="watchcountdowntext"><?=$lng_bids;?></div>
							<div class="watchaucdelete"></div>
						</div>
						<div style="height: 15px;">&nbsp;</div>
						<?
							$i=1;
							while($obj1 = mysql_fetch_array($rssel1))
							{
							$startdate = substr($obj1["auc_start_date"],0,10);
							if($obj1["is_close"]==0){ $status=$lng_bidliveauction; } 
							elseif($obj1["is_close"]==1){ $status=$lng_ended; } 
						?>
						<div class="even-row">
							<div class="watchevenproductimage"><a href="auction_<?=str_replace(" ","_",strtolower($obj1["name"]));?>_<?=$obj1["auctionID"];?>.html"><img src="uploads/products/thumbs_big/thumbbig_<?=$obj1["picture1"];?>" style="border: medium none ;"></a></div>						
							<div class="watchevenproductdesc">
								<div class="watchauction_decription">
								<a href="auction_<?=str_replace(" ","_",strtolower($obj1["name"]));?>_<?=$obj1["auctionID"];?>.html" class="black_link"><?=stripslashes($obj1["name"]);?></a><br /><br />
							    <?=stripslashes(choose_short_desc($obj1["short_desc"],120));?><a href="auction_<?=str_replace(" ","_",strtolower($obj1["name"]));?>_<?=$obj1["auctionID"];?>.html" class="black_link"><?=$lng_linkmore;?></a>
								</div>
							</div>
							<div class="watchevenproductprice"><?=arrangedate($startdate);?></div>
							<div class="watchevenproductbidder" style="font-size: 12px;"><strong><?=$status;?></strong></div>
							<div class="watchevenproductcountdown"><span class="red-text-12-b">-<?=getTotalPlaceBids($obj1["auctionID"]);?></span></div>
							<div class="watchdelete" style="height: 15px;">
								<img src="<?=$lng_imagepath;?>icon_gbkplus.gif" onclick="BidHistoryPlus('bidd<?=$obj1["auctionID"]; ?>','plusimage<?=$obj1["auctionID"]; ?>','minusimage<?=$obj1["auctionID"]; ?>');" id="plusimage<?=$obj1["auctionID"]; ?>" align="right"/>							
						<img src="<?=$lng_imagepath;?>icon_gbkminus.gif" onclick="BidHistoryMinus('bidd<?=$obj1["auctionID"]; ?>','plusimage<?=$obj1["auctionID"]; ?>','minusimage<?=$obj1["auctionID"]; ?>');" id="minusimage<?=$obj1["auctionID"]; ?>" style="display: none;" align="right"/>
							</div>		
					</div>					  
					<div id="bidd<?=$obj1["auctionID"];?>" style="width: 680px; float: right; margin-top: -85px; padding-right: 18px; position: relative; display: none;">
						<div id="detailsimage"></div>
						<div id="bidhistory_bid_history">
							<div id="historytop"></div>
								<div id="historydetails">
								<? getBidHistory($obj1["auctionID"],$uid) ?>
								</div>
							<div id="historybot"></div>
						</div>
						</div>
						<div id="cleaner"></div>
						<?
							}
						?>
						<div class="strip">
						<div style="padding-top: 2px;">
					  <?
					  if($PageNo1>1)
					  {
					    $PrevPageNo1 = $PageNo1-1;
				 	  ?>
						  <A class="alink" href="bid_history_<?=$PrevPageNo1;?>_N.html">&lt; <?=$lng_previouspage;?></A>
					  <?
						if($totalpage1>2 && $totalpage1!=$PageNo1)
						{
					  ?>
						<span class="paging">&nbsp;|</span>
					  <?
							}
					   }
					  ?>&nbsp;
					  <?php
					  if($PageNo1<$totalpage1)
					  {
						 $NextPageNo1 =	$PageNo1 + 1;
					  ?>
					  <A class="alink" href="bid_history_<?=$NextPageNo1;?>_N.html"><?=$lng_nextpage;?> &gt;</A>
					  <?
					   }
					  ?>
					 </div>
					</div>
				</div>
				<div class="bottomline">
					<div class="leftsidecorner"></div>
					<div class="middlecorner"></div>
					<div class="rightsidecorner"></div>
				</div>
			</div>
			<?
			}
			else
			{
		    ?>
			<div class="inner-container">
				<div class="titlebar">
					<div class="leftbar"></div>
					<div class="middlebar"><div class="page_title_font"><?=$lng_myauctionsavenue;?></div></div>
					<div class="rightbar"></div>
				</div>
				<div class="bodypart">	
					<div style="height:15px;"></div>
					<div class="noauction_message"><?=$lng_donthaveanybid;?></div>
					<div style="height:15px;"></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>
