<?php
require dirname(__FILE__) . "/dzsck.php";
include "../conf/pager.class.php";
$CurrentPage = (isset($_GET["page"]) ? $_GET["page"] : 1);
if($_GET['type']=='del' and $_GET['id']!=''){  //删除一个尝鲜
	$cm->delete('d_shooting',"s_id in(".$_GET['id'].")");
	echo backs("删除成功！");
	exit();
}

 //今日影视统计
$y = date("Y");
$m = date("m");
$d = date("d");
$day_start = mktime(0,0,0,$m,$d,$y);
$cm->query("SELECT * FROM d_shooting where s_time > '" .$day_start."' order by s_id desc");
$todaymum=$cm->db_num_rows();
 
if($_GET['type']=='s'){	
	$cm->query("SELECT * FROM d_shooting where s_name like '%".$_POST['key']."%' order by s_id desc");	
}else{
	$cm->query("SELECT * FROM d_shooting order by s_id desc");
}
		$mypagesnum=$cm->db_num_rows();
		$p_pageSize = 10;
        $myPage = new pager($mypagesnum, intval($CurrentPage), $p_pageSize);
        $min_page = ($CurrentPage - 1) * $p_pageSize;
		
if($_GET['type']=='s'){
	$cm->query("SELECT * FROM d_shooting where s_name like '%".$_POST['key']."%' order by s_id desc LIMIT " . $min_page . "," . $p_pageSize);
}else {
	$cm->query("SELECT * FROM d_shooting order by s_id desc LIMIT " . $min_page . "," . $p_pageSize);
}
?>

<!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="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商品列表</title>
<link href="public/css/base.css" rel="stylesheet" type="text/css" />
<link href="public/css/style.css" rel="stylesheet" type="text/css" />
<script language="javascript"> 
	function delcfm() { 
		if (!confirm("确认要删除？")) { 
			window.event.returnValue = false; 
		} 
	} 
</script> 
</head>
<body>
	<div class="tab" id="tab"> 
		<a class="selected" href="shooting.php">尝鲜列表(<b>&nbsp;<?=$mypagesnum?>&nbsp;</b>)</a>
		<a class="selected" href="addshooting.php">添加影视</a>
		<span style="float:left">&nbsp;&nbsp;&nbsp;今日新增&nbsp;
			<strong style="color:#F00"><?=$todaymum?></strong>&nbsp;个尝鲜
		</span>
		<form name="forms1" method="post" action="?type=s" style="float:right">
			影视名：<input type="text" name="key" value="" class="text_value" style="height:20px; width:120px" />
			<button type="submit" class="button" style="height:20px; line-height:20px">搜索</button> 
		</form>
	</div>
	<div class="page_main">
		<div class="page_table table_list">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<th width="11%"><center>影视名</center></th>
					<th width="10%">添加时间</th>
					<th width="10%">影视封面图</th>
					<th width="18%"><center>影视简介</center></th>
					<th width="15%"><center>操作</center></th>
				</tr>
				<?php
					while($row = $cm->fetch_array($rs)){
				?>
				<tr>
					<td style=" <? if($row['s_time']>$day_start){?> color:#F00;<? }?>">
						<center><?=$row['s_name']?></center>
					</td>
					<td style=" <? if($row['s_time']>$day_start){?> color:#F00;<? }?>"><?=date('Y-m-d',$row['s_time'])?></td>
					<td>
						<img src="<?=$row['s_pic']?>" width="60px" height="40px">
					</td>
					<td>
						<?=$row['s_content']?>
					</td>
					<td>
						<center>
							<a onClick="delcfm()" href="?type=del&id=<?=$row['s_id']?>">删除</a>&nbsp;&nbsp;
							<a href="editshooting.php?s_id=<?php echo $row['s_id']?>">修改</a>&nbsp;&nbsp;
						</center>
					</td>
				</tr>
				<?php
				}
				?>
			</table>
		</div>
	</div>
<div class="page_tool">
  <div class="page"><?php
     $pageStr= $myPage->GetPagerContent();
	 echo $pageStr;
    ?></div>
</div>

<div class="fn_clear"></div>
</body>

</html>