<?php
include("../includes/page_utf_class.php");
//=======================
if($_GET["submit"]==lang_show('delete'))
{
	
	if(isset($_GET["del"]) && is_array($_GET["del"]))	
	{
		include_once("../includes/tag_inc.php");
		foreach($_GET["del"] as $id)
		{
			$db->query("delete from ".EXHIBIT." where id='$id'");
			del_tag($id,3);
		}
	}
}
elseif($_GET["submit"]==lang_show('rc'))
{
	if(isset($_GET["del"]) && is_array($_GET["del"]))	
	{
		$id=implode(",",$_GET["del"]);
		$sql="update ".EXHIBIT." set statu=2 where id in ($id)";
		$db->query($sql);
	}
}
elseif($_GET["submit"]==lang_show('unrc'))
{
	if(isset($_GET["del"]) && is_array($_GET["del"]))	
	{
		$id=implode(",",$_GET["del"]);
		$sql="update ".EXHIBIT." set statu=1 where id in ($id)";
		$db->query($sql);
	}
}
?>
<!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>
<TITLE> <?php echo lang_show('admin_system');?></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="main.css" rel="stylesheet" type="text/css" />
</HEAD>
<body>

<form name=frmlist action="" method="get">
<?php
if(!empty($_GET['firstRow']))
{
?>
<input name="firstRow" type="hidden" value="<?php echo $_GET['firstRow'];?>">
<?php
}
if(!empty($_GET['firstRow']))
{
?>
<input name="totalRows" type="hidden" value="<?php echo $_GET['totalRows'];?>">
<?php } ?>
<script language="javascript">
function do_select()
{
	 var box_l = document.getElementsByName("del[]").length;
	 for(var j = 0 ; j < box_l ; j++)
	 {
	  	if(document.getElementsByName("del[]")[j].checked==true)
	  	  document.getElementsByName("del[]")[j].checked = false;
		else
		  document.getElementsByName("del[]")[j].checked = true;
	 }
}
function checkstate() 
{
	 var box_l = document.getElementsByName("del[]").length;
	 var count=0;
	 for(var j = 0 ; j < box_l ; j++)
	 {
	  	if(document.getElementsByName("del[]")[j].checked==false)
	  	  count++;
	 }
	  if(count==box_l)
	 {
		alert("<?php echo lang_show('fchecked');?>");
		return false;
	 }
	 else
	 {
		 if(confirm("<?php echo lang_show('suerdelit');?>"))
		 {
			 return true;
		 }
		 else
			 return false;
	 }
} 
</script>
<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('news_list');?></div>
	<div class="bigboxbody">
	<table border="0" width="100%" cellspacing="0" cellpadding="0"><tr><td class="searh_left"><span  style="font-size:12px; "><?php echo lang_show('title');?></span></td><td width="*%"><input class="text" name="keyword" value="<?php echo $_GET["keyword"];?>" type="text"></td> </tr><tr><td> </td><td><input name="" class="btn" type="submit" value="<?php echo lang_show('search');?>">
		<input name="m" type="hidden" value="<?php echo $_GET['m'];?>">
	<input name="s" type="hidden" value="<?php echo $_GET['s'];?>">
	</td>
    </tr>
    </table>
  <table width="100%" border="0" align="center" cellpadding="4" cellspacing="0" >
    <tr class="theader"> 
      <td width="20" ><input onClick="do_select()" name="" type="checkbox" class="checkbox"></td>
      <td width="*" > <?php echo lang_show('title');?></td>
      <td width="76" align="center" ><?php echo lang_show('is_support');?></td>
      <td width="180" align="center" ><?php echo lang_show('show_time');?></td>
      <td width="161" align="center" ><?php echo lang_show('post_time');?></td>
      <td width="75" align="center" ><?php echo lang_show('manager');?></td>
    </tr>
    <?php 
	$sqld=NULL;
	if(!empty($_GET["keyword"]))
		$sqld=" where title like '%".trim($_GET['keyword'])."%' ";
	$sql="select * from ".EXHIBIT." $sqld order by id desc";
		//=============================
	  	$page = new Page;
		$page->listRows=20;
		if (!$page->__get('totalRows')){
			$db->query($sql);
			$page->totalRows = $db->num_rows();
		}
        $sql .= "  limit ".$page->firstRow.",20";
		$pages = $page->prompt();
	//=====================
		$db->query($sql);
		$re=$db->getRows();
		unset($_GET['s']);
	    $getstr=implode('&',convert($_GET));
		if(count($re))
		{
			foreach($re as $va)
			{
			?> 
		<tr> 
		  <td width="20"><input name="del[]" type="checkbox" class="checkbox" id="del[]" value="<?php echo $va['id']; ?>"></td>
		  <td>
           <?php echo $va['statu']?"<img src='../image/default/on.gif' />":"<img src='../image/default/off.gif' />";?>
           <?php if($va['pic']) echo "<img src='../image/default/image_s.gif'>";?>
		   <?php echo $va['title']; ?>
		   </td>
		   <td align="center"><?php if ($va['statu']>=2) echo lang_show('rc'); else  echo lang_show('nrc'); ?></td>
		   <td width="180" align="center">
		   <?php
		   		if (!empty($va['stime']))
				     $sttime=date("Y-m-d",$va['stime']);
				else
					$sttime=NULL;
                if (!empty($va['etime']))
				    $entime=date("Y-m-d",$va['etime']);
				else
					$entime=NULL;
		    echo $sttime." - ".$entime; ?>
			</td>
		  <td width="161" align="center"><?php echo $va['addTime']; ?> </td>
		  <td width="75" align="center">
		  <a href="module.php?m=exhibition&s=exhibit.php&id=<?php echo $va['id']."&$getstr" ;?>"><?php echo $editimg;?></a>
		  </td>
		</tr>
			<?php 
			}
		}
	 ?> 
	 <tr>
	  <td colspan="2">
		<input onClick="return checkstate();" class="btn" type="submit" name="submit" value="<?php echo lang_show('delete');?>">
		<input class="btn" type="submit" name="submit" value="<?php echo lang_show('rc');?>">
		<input class="btn" type="submit" name="submit" value="<?php echo lang_show('unrc');?>">
		<input name="action" type="hidden" id="action" value="submit">
	  </td>
	  <td colspan="4" align="center"><div class="page"><?php echo $pages?></div></td>
	</tr>
  </table>

  </div>
</div>
  </form>
</body>
</html>
