<?php 
session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
	
	$ls=$_GET['ls'];
	$id=$_GET['id'];
	$modiid=$_POST['modiid'];
	$userName=trim($_POST['userName']);
	$userRealName=$_POST['userRealName'];
	$usercompany=$_POST['usercompany'];
	$userPwd=$_POST['userPwd'];
	$userEmail=strtolower(trim($_POST['userEmail']));
	$userWeb=strtolower(trim($_POST['userWeb']));
	$userMemo=$_POST['userMemo'];	
	$userTime=$_POST['userTime'];
	$userNum=$_POST['userNum'];

	$lsc=$_GET['lsc'];
	$lsctype=$_GET['lsctype'];
	$searchproductName=trim($_POST['searchproductName']);
	if($searchproductName==''){$searchproductName=$_GET['searchproductName'];}// 分页传过来的变量

	
	$nowusernum=$_GET['userNum'];

	$ls_msg="产品反馈操作";
	
	
	
	
	switch ($ls)
	{
		case "del":
		
			$del_sql="delete from ls_pro_feedback where id=".$id." ";
			//echo $del_sql;
			$del_query=$opendb->query($del_sql);
			$ls_msg="删除操作成功！";
			
			break;
	}
	

switch ($lsc)
	{
		case "all":			
			$addsearchstr=" where cateNameID = 0 " ;
			$ls_msg="全部";
		 	break;
		case "type":			
			$addsearchstr=" where continent='".$lsctype."' and cateNameID = 0 " ;
			$ls_msg="筛选条件： ".$lsctype." 的记录";
		 	break;


}

?>
<!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=utf-8">
		<link href="css/admin.css" rel="stylesheet" type="text/css">
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function turnit(ss,ii){
 //循环判断，ss为总列表数,ii为当前列
 for (i=1;i<=ss;i++){
   //错误过滤，当i=1至ss中有一项以上出错，自动过滤
  try{
   //当i=ii时展开目录数，否则关闭
   if (i==ii){
    //判断i列的目录数是否展开，没有就展开，否则关闭
    if (document.getElementById("content"+i).style.display=="none"){
     document.getElementById("content"+i).style.display="";
        document.getElementById("img"+i).src="images/up.gif";
    }else{
     document.getElementById("content"+i).style.display="none"; 
        document.getElementById("img"+i).src="images/down.gif";
    }
   }else{
    document.getElementById("content"+i).style.display="none"; 
       document.getElementById("img"+i).src="images/down.gif";
   }
  }catch(e){}
 }
}
</script>
	</head>
	<body>
		<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
			<tr>
				<td height="18" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>产品反馈</strong></font></div>
				</td>
			</tr>
			
			<tr>
			  <td height="213" valign="top" bgcolor="#dee7ff"><br>
                  <?php 
	if( isset($_GET['page']) )
	{$page = intval( $_GET['page'] );	}
	else
	{$page = 1;	}
	
	if($_POST['gopage']!="")
	{$page =$_POST['gopage']; 
	}

	// 每页数量
	if($usersNum!=0)
	{	$PageSize = $usersNum;}
	else
	{	$PageSize = 20;}
	
	// 获取总数据量
	/********************************************************************************/
	
	$sql="select * from ls_pro_feedback  where cateNameID = 0 ";
	if($searchproductName!="")
	{
		$sql.="and requirement like '%".$searchproductName."%' or name like '%".$searchproductName."%' or tel like '%".$searchproductName."%' or company like '%".$searchproductName."%' or email like '%".$searchproductName."%' ".$wherestr1;
		$ls_msg="包含".$searchproductName."的信息";
	}
	else
	{
		if( $lsc=="type" )
		{
			$sql.=$addsearchstr.$wherestr1;
		}
		else
		{
			$sql.=$wherestr2 ;
		}
	}
	//echo $sql;
	$result=$opendb->query($sql);
	
	/********************************************************************************/
	// 获取总数据量
	
	$row = mysql_num_rows($result);
	$amount = $row;
	
	// 记算总共有多少页
	if( $amount ){
	   if( $amount < $PageSize ){ $page_count = 1; }			   //如果总数据量小于$PageSize，那么只有一页
	   if( $amount % $PageSize ){								  //取总数据量除以每页数的余数
		   $page_count = (int)($amount / $PageSize) + 1;		   //如果有余数，则页数等于总数据量除以每页数的结果取整再加一
	   }else{
		   $page_count = $amount / $PageSize;					  //如果没有余数，则页数等于总数据量除以每页数的结果
	   }
	}
	else{
	   $page_count = 0;
	}
	
	// 翻页链接
	$page_string = '';
	$pagecatestr="";
	if( $page == 1 ){
	   $page_string .= '首页 | 上一页 |';
	}
	else{
	   $page_string .= '<a href=?&page=1&'.$pagecatestr.'><u><font color=\"#0000FF\">首页</font></u></a> | <a href=?&page='.($page-1)."&".$pagecatestr.'><u><font color=\"#0000FF\">上一页</font></u></a> | ';
	}
	if( ($page == $page_count) || ($page_count == 0) ){
	   $page_string .= ' 下一页 | 尾页';
	}
	else{
	   $page_string .= ' <a href=?&page='.($page+1).'&'.$pagecatestr.'><u><font color=\"#0000FF\">下一页</font></u></a> | <a href=?&page='.$page_count.'&'.$pagecatestr.'><u><font color=\"#0000FF\">尾页</font></u></a>';
	}
		 $page_string .= " &nbsp;&nbsp;页次：<font color='#FF0000'><b>".$page."</b></font>/<b>".$page_count."</b>页";
		 $page_string .= " &nbsp;&nbsp;<b>".$PageSize."</b>个客户每页";
	
	
 
?>
	         <form action="<?php echo "?&lsc=".$lsc."&lsctype=".$lsctype."&searchproductName=".$searchproductName; ?>" method="post" name="searchfm" id="searchfm">
				<table border="0" width="100%" align="center">
						<tr>
							<td width="42%">提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
                            <td width="22%" align="right"><span style="padding-left:6px;"><strong>查找：</strong>
                              <input type="text" name="searchproductName" size="12" maxlength="50" />
                              <input type="submit"  value="查询" />
                            </span></td>
                            <td width="13%" align="right" bgcolor="#DBEEF0" style="padding-left:6px;"><div align="right">到
                              <input name="gopage" type="text" size="3" />
                              页
                              <input type="submit" name="Submit" value="GO" />
                            </div></td>
                            <td width="7%" align="right"><span style="padding-left:6px;"><a href="?lsc=all">全部</a></span></td>
                            <td width="16%" align="right">共 <b>
                              <?=$row?>
                            </b> 条信息</td>
                        </tr>
			   </table>
	    </form>	
					<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
					 
<tr bgcolor="#B9DAFF">
  <td width="3%" align="center" >序号</td> 
						<td width="20%" align="center" height="38">反馈信息</td>
                       <td width="8%" align="center">客户姓名</td>
                       <td width="15%" align="center">公司名称</td>
                       <td width="13%" align="center">E-mail</td>
					   <td width="10%" align="center">网址</td>
					   <td width="15%" align="center">对应产品名</td>
					   <td width="10%" align="center">发表时间</td>
                       <td width="3%" align="center" >收展</td>
                       <td width="3%" align="center" >删除</td>
					  </tr>
					 <?php 
					 		//查询数据
					$user_sql=$sql." order by date desc  limit ". ($page-1)*$PageSize .",".$PageSize." ";	

					$user_query=$opendb->query($user_sql);
			
					 $i=1;
					  while ($user_rows=mysql_fetch_assoc($user_query))
					  {
					  ?>
    <tbody id='ZH_<?=$user_rows['ID']?>' >
    <tr bgcolor='#f4f4f4' onMouseOver="this.style.backgroundColor='#CCFFCC'"
    onMouseOut="this.style.backgroundColor='#f4f4f4' ">
  <td align='left' style='padding-left:10px;' height='25' ><?=$i?></td>
  <td align='left' style='padding-left:10px;' height='25' ><?=mb_substr($user_rows['requirement'], 0, 100, 'utf-8') ?></td>
  <td align='left' style='padding-left:10px;' height='25'><?=$user_rows['name'] ?></td>
  <td align='left' style='padding-left:5px;' height='25'><?=trim($user_rows['company'])?></td>
  <td align='left' style='padding-left:10px;' height='25'><a href="mailto:<?=$user_rows['email']?>">
    <?=$user_rows['email']?>
    </a></td>
  <td align='left' style='padding-left:10px;'><?=$user_rows['http']?></td>
  <td align='left' style='padding-left:10px;' height='25'><?=$user_rows['path']?></td>
  <td align='left' style='padding-left:10px;' height='25'><?=str_replace(substr($user_rows['date'],-3),"",$user_rows['date'])?></td>
  <td align='center'><a href="javascript:void(0);" onclick="turnit(<?=$row?>,<?=$i?>);"><img src="images/down.gif" id="img<?=$i?>" /></a></td>
  <td align='center'><?
						if($user_rows['userAdmin']==1)
						{
							echo "	<img src='images/b_undrop.png' border='0'>";
						}
						if($user_rows['userAdmin']==0)
						{
							echo "<a href='?page=$page&id=".$user_rows['ID']."&ls=del' onclick='return ConfirmDel();' title='删除'><img src='images/b_drop.png' border='0'></a>";
						 }?></td>
						</tr>
                        <tr style="display:none;" id="content<?=$i?>">
                            <td>&nbsp;</td>
                            <td colspan="9">
                            	<table width="100%" >
                                    <tr>
                                        <td ><p style="padding:0px; margin:0px;"><?=$user_rows['requirement']?></p></td>
                                    </tr>
                                    <tr>
                                        <td ><p style="color:#999; font-style:italic; padding:0px; margin:0px;">IP: <?=$user_rows['ip'] ?>， &nbsp;&nbsp; 国家区域：<?=trim($user_rows['home'])?>， &nbsp;&nbsp; 浏览器信息：<?=trim($user_rows['explorer'])?>， &nbsp;&nbsp; 操作系统：<?=trim($user_rows['system'])?>， &nbsp;&nbsp; 发表时间：<?=$user_rows['date']?></p></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
						</tbody>
					   <?
						$i++;
					  }
					 ?> 
                     

							<tr>
							<td align="center" colspan="13" bgcolor="#B9DAFF" height="30"><? echo( $amount>$PageSize?$page_string:""); ?> </td>
					  </tr>
				</table>
				</td>
			</tr>
		</table>
	</body>
</html>