<?
	include("connect.php");
	include_once("admin.config.inc.php");
	include("security.php");
	include("config_setting.php");
	include("functions.php");

	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 * from news where news_title like '$order%' order by id";
		}
		else
		{
			$query = "select * from news order by id";
		}
			$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">
</head>

<body bgcolor="#ffffff" style="padding-left:10px">
<table width="100%" cellPadding="0" cellSpacing="10">
  <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="addnews.php"> 添加. </A> 
           <!--/options-->
        	 </TD>
          </TR>
	    </TBODY>
	   </TABLE>
	 </TD>
  </TR>
<Tr>
<td>
	
<?
	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">没有数据</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="2%">序</td>
			  <td width="20%">类型</td>
			  <td width="20%">标题</td>
			  <!--td width="35%">正文</td-->
			  <td width="10%">日期</td>
			  <td width="10%" 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->id;
				$newstype=$row->news_type;
				if($newstype=='1')$newstype="公告";
				if($newstype=='2')$newstype="新闻";
				$newstitle=$row->news_title;
				$newsdate=$row->news_date;
				$newscontent=$row->news_short_content;

				$cellColor = "";
				$cellColor = ConfigcellColor($i);
				?>
		  	<tr class="<?=$cellColor?>">
			  <td align="center">
				<?=$srno;?></td>	
				<td><?=stripslashes($newstype)?></td>
			  <td><?=stripslashes($newstitle)?></td>
			  <!--td><?=stripslashes($newscontent)?></td-->
			  <td><?=arrangedate($newsdate);?></td>
			  <td align="center">
			<input class="bttn-s" onClick="window.location.href='addnews.php?news_edit=<?=$id;?>'" type="button" value="编辑">
			<input name="button" type="button" class="bttn-s" value="删除" onClick="window.location.href='addnews.php?news_delete=<?=$id;?>'">
			</td>
			</tr>
				 <?
			  }
				 ?>
		  </tbody>
		  </table>
		</form>
	</td>
	</tr>
</table>
<?
	}
?>
	  <?php
		if($PageNo>1)
		{
                  $PrevPageNo = $PageNo-1;

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