<?
	include("connect.php");
	include_once("admin.config.inc.php");
	include("security.php");
	include("config_setting.php");
	$type1 = "1";
	$type3 = "3";
	include("pagepermission.php");

$PRODUCTSPERPAGE = 15; 
if(!$_GET['order'])
$order = "";
else
$order = $_GET['order'];
if(!$_GET['pgno'])
{
	$PageNo = 1;
}
else
{
	$PageNo = $_GET['pgno'];
}
/********************************************************************
     Get how many products  are to be displayed according to the  Events
********************************************************************/
	$StartRow =   $PRODUCTSPERPAGE * ($PageNo-1);
/***********************************************/
if($order!="")
{
	$query = "select *,p.name from auction a left join products p on a.productID=p.productID left join registration r on r.id=a.buy_user where p.name like '$order%' and featured_flag='0'";
}
else
{
	$query = "select *,p.name from auction a left join products p on a.productID=p.productID left join registration r on r.id=a.buy_user where featured_flag='0'";
}

	if($_REQUEST["aucstatus"]!="")
	{
		$ast = $_REQUEST["aucstatus"];
		$query .= " and auc_status='".$_REQUEST["aucstatus"]."'";
	}
	
	$query .= " order by a.auc_status";

	$result=mysql_query($query) or die (mysql_error());
	$totalrows=mysql_num_rows($result);
	$totalpages=ceil($totalrows/$PRODUCTSPERPAGE);
	$query .= " LIMIT $StartRow,$PRODUCTSPERPAGE";
	$result =mysql_query($query);
	$total = mysql_num_rows($result);
	
?>
<!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 rel="stylesheet" href="main.css" type="text/css">
<script language="javascript" type="text/javascript">
function SubmitForm()
{
	document.f3.submit();
}	
</script>
</head>

<body bgcolor="#ffffff" style="padding-left:10px">
<table width="100%" cellPadding="0" cellSpacing="10">
  <!--DWLayoutTable-->
  <TR> 
    <TD class="H1">管理拍卖</TD>
  </TR>
  <TR>
    <TD background="images/vdots.gif"><IMG height=1 src="images/spacer.gif" width=1 ></TD>  </TR>
  <TR>
    <TD><!--content-->
	    <TABLE cellSpacing="2" cellPadding="2" width="100%" >
    	 <TBODY>
           <TR>
             <TD colspan="2"> 
           <!--options-->
             <IMG height=11 src="images/001.gif" width=8 ><A class=la href="addauction.php"> 新增一个拍卖. </A> 
           <!--/options-->
        	 </TD>
          </TR>
		  <tr>
		  	<td colspan="2">&nbsp;</td>
		  </tr>
		  <!--tr>
            <td class="tdTextBold"><B>View By Main Product</B></td>
            <td>
            <form name="f3" action="manageauction.php" method="post">
              <table border="0" cellpadding="0" cellspacing="0" width="200" align="right">
                <tr>
                    <td align="right"><strong>Auction Status:</strong>&nbsp;</td>
                    <td><select name="aucstatus" onchange="SubmitForm();">
                        <option value="">All</option>
                        <option value="1" <?=$ast=="1"?"selected":"";?>>Future</option>
                        <option value="2" <?=$ast=="2"?"selected":"";?>>Active</option>
                        <option value="3" <?=$ast=="3"?"selected":"";?>>Sold</option>
                        <option value="4" <?=$ast=="4"?"selected":"";?>>Pending</option>
                    </select>
                    <input type="hidden" name="pgno" value="1" />
              </table>
           </form>
          </td>
		  </tr-->
	    </TBODY>
	   </TABLE>
	   <br>
	<!--FORM id="form1" name="form1" action="manageauction.php" method="post">
      <TABLE cellSpacing="0" cellPadding="1" border="0" width="500">
        <TBODY>
        <TR>
          <TD><a class="la" href="manageauction.php?aucstatus=<?=$ast;?>">All</a></TD>
          <TD class="lg">|</TD>
          <TD><a class="la" href="manageauction.php?order=A&aucstatus=<?=$ast;?>">A</a></TD>
          <TD class="lg">|</TD>
          <TD><a class="la" href="manageauction.php?order=B&aucstatus=<?=$ast;?>">B</a></TD>
          <TD class="lg">|</TD>
          <TD><a class="la" href="manageauction.php?order=C&aucstatus=<?=$ast;?>">C</a></TD>
          <TD class="lg">|</TD>
          <TD><a class="la" href="manageauction.php?order=D&aucstatus=<?=$ast;?>">D</a></TD>
          <TD class="lg">|</TD>
          <TD><a class="la" href="manageauction.php?order=E&aucstatus=<?=$ast;?>">E</a></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=F&aucstatus=<?=$ast;?>">F</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=G&aucstatus=<?=$ast;?>">G</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=H&aucstatus=<?=$ast;?>">H</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=I&aucstatus=<?=$ast;?>">I</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=J&aucstatus=<?=$ast;?>">J</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=K&aucstatus=<?=$ast;?>">K</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=L&aucstatus=<?=$ast;?>">L</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=M&aucstatus=<?=$ast;?>">M</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=N&aucstatus=<?=$ast;?>">N</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=O&aucstatus=<?=$ast;?>">O</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=P&aucstatus=<?=$ast;?>">P</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=Q&aucstatus=<?=$ast;?>">Q</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=R&aucstatus=<?=$ast;?>">R</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=S&aucstatus=<?=$ast;?>">S</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=T&aucstatus=<?=$ast;?>">T</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=U&aucstatus=<?=$ast;?>">U</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=V&aucstatus=<?=$ast;?>">V</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=W&aucstatus=<?=$ast;?>">W</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=X&aucstatus=<?=$ast;?>">X</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=Y&aucstatus=<?=$ast;?>">Y</A></TD>
          <TD class="lg">|</TD>
          <TD><A class="la" href="manageauction.php?order=Z&aucstatus=<?=$ast;?>">Z</A></TD>
		  </TR></TBODY></TABLE>
		</form-->
<?
	if($total<=0)
	{
?>
	<table width="70%" border="0" cellspacing="1" cellpadding="1" align="center" bgcolor="#000000">
      <tr> 
        <td> 
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
           <tr> 
             <td class=th-a> 
              <div align="center">No product To Display</div>
             </td>
           </tr>
         </table>
        </td>
      </tr>
    </table>
<?
	}
	else
	{
?>
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
	  <tr>
		<td>
		<form id="form2" name="form2" action="" method="post">  
          <table width="100%"  cellSpacing="0" class="t-a" border="1">
           <tbody>
		    <TR class="th-a"> 
			  <td width="6%">序号</td>
			  <td width="6%">拍卖号码</td>
  			  <td width="22%">商品名称</td>
			  <td width="15%">最终价格</td>
			  <td width="5%">状态</td>
			   <td width="5%">热拍</td>
			   <td width="5%">用户新体验</td>
			  <td width="15%">类型</td>
			  <!--<TD  width="10%">InStock</TD>-->
			  <td width="11%">获胜者</td>
			  <td width="20%" align="center">操作</td>
		    </TR>
			<?
			  for($i=0;$i<$total;$i++)
			  {

				 if($PageNo>1)
				 {
					$srno = ($PageNo-1)*$PRODUCTSPERPAGE+$i+1;
				 }
				 else
				 {
					$srno = $i+1;
				 }

				$row = mysql_fetch_object($result);
				$id=$row->auctionID;
				$pname=stripslashes($row->name);
				$fprice=$row->auc_final_price;
				$status=$row->auc_status;
					if($row->time_duration=="20sa"){$auctype="20秒拍卖";}
					if($row->time_duration=="15sa"){$auctype="15秒拍卖";}
					if($row->time_duration=="10sa"){$auctype="10秒拍卖";}
				$winner = $row->username;
				$cellColor = "";
				$cellColor = ConfigcellColor($i);
				?>
		  	<tr class="<?=$cellColor?>">
			  <td align="center"><?=$srno;?></td>	
			  <td align="center"><?=$id;?></td>
			  <td align="center"><?=$pname?></td>
			  <td align="right"><?=$fprice==""?"&nbsp":$fprice;?></td>
			  <td align="center">
			  <?	
			  	if($row->is_close==0&&$row->auc_start_time>time()){ echo "<font color=green>未开始</font>";}
			  	if($row->is_close==0&& $row->auc_start_time<time()){ echo "<font color=red>正在进行</font>";}
			  	if($row->is_close==1){ echo "<font color=blue>已卖出</font>";}
				
			  ?>
			  </td>
			  <td align="center">
			  <?	
			  	if($row->is_hot==0){ echo "<font color=green>否</font>";}
			  	if($row->is_hot==1){ echo "<font color=red>是</font>";}
			  ?>
			  </td>
			  <td align="center">
			  <?	
			  	if($row->is_exprice==0){ echo "<font color=green>否</font>";}
			  	if($row->is_exprice==1){ echo "<font color=red>是</font>";}
			  			  ?>
			  </td>

			  <td nowrap="nowrap" align="center"><?=$auctype==""?"&nbsp":$auctype;?></td>
			  <td align="center"><?=$winner==""?"&nbsp":$winner;?></td>
			  <td align="left">
			<input class="bttn-s" onClick="window.location.href='addauction.php?auction_edit=<?=$id;?>'" type="button" value="编辑">			            <input name="button" type="button" class="bttn-s" value="删除" onClick="window.location.href='addauction.php?auction_delete=<?=$id;?>'">
			<? if($status==3){ ?>
            <input name="button" type="button" class="bttn-s" value="克隆" onClick="window.location.href='addauction.php?auction_clone=<?=$id;?>'">
			<? } ?>
			</td>
			</tr>
			 <?
			 }
			 ?>
			</tbody>
		</table>
	</form>
</td>
</tr>
</table>
<?
}
?>
	  <?php
		if($PageNo>1)
		{
                  $PrevPageNo = $PageNo-1;

	    ?>
	  <A class="paging" href="manageauction.php?order=<? echo $order ?>&pgno=<?php echo $PrevPageNo; ?>&aucstatus=<?=$ast;?>">&lt; 上一页</A>
	  <?
	   }
	  ?> &nbsp;&nbsp;&nbsp;
	  <?php
        if($PageNo<$totalpages)
        {
         $NextPageNo = 	$PageNo + 1;
      ?>
	  <A class="paging" href="manageauction.php?order=<? echo $order ?>&pgno=<?php echo $NextPageNo;?>&aucstatus=<?=$ast;?>">下一页 &gt;</A>
	  <?
       }
      ?>
</TD>
</TR>
</table>
</body>
</html>
