<?php 
	require_once('_approot.php');
	if($_POST['pagenum1']!="")//每页显示的留言数量
	{$_SESSION['pagenum']=$_POST['pagenum1'];}//存入session
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php 
	
	$openck=new cktb();
	if($openck->checktable("ls_pro_feedback","CREATE TABLE ls_pro_feedback (ID INT( 4 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , requirement TEXT NULL , name VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , company VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , tel VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , email VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , date VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , path VARCHAR( 1000 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL, address VARCHAR(500) NULL, fax VARCHAR(100) NUll, http VARCHAR(100)  NULL, proID INT( 4 ) NULL, ip VARCHAR( 50 ) NULL, explorer VARCHAR( 100 ) NULL, home VARCHAR( 300 ) NULL, system VARCHAR( 50 ) NULL, enable INT(1) NULL DEFAULT  '1') ENGINE = INNODB;"))	$ls_msg = $ls_msg .$openck->ls_msg;
	
	$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'];
	
	$selectcate=$_GET['selectcate'];

	$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   " ;
			$ls_msg="全部";
		 	break;
		case "type":			
			$addsearchstr=" where continent='".$lsctype."'  " ;
			$ls_msg="筛选条件： ".$lsctype." 的记录";
		 	break;
		case "unenable":
			$unenable_sql="update ls_pro_feedback set enable=0 where id=".$id." ";
			//echo $unenable_sql;
			$unenable_query=$opendb->query($unenable_sql);
			$ls_msg="操作成功！";
			echo "<script>window.open(\"menu.php\",   \"leftFrame\")   </script>";
			break;
}

	$download_sql="SELECT * FROM ls_functioncates where enable=1  and functionName='询盘分类' order by Num asc";//count the error by searchtype
	$download_query=$opendb->query($download_sql);
	
	function cateName_s($id){
		if($id != NULL){
		$function_sql ="select * from ls_functioncates where ID = ".$id;
		$opendb=new mydb();
		$function_query=$opendb->query($function_sql);
		$function_rows=mysqli_fetch_assoc($function_query);
			if($function_rows['cateName'] != ""){
				return $function_rows['cateName'];
			}else{
				return "产品";
			}
		}else{
			return "其它";
		}
	}
?>
<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">
        <link rel="stylesheet" href="css/style2.css" />
<script language="JavaScript" src="js/ls.js"></script>
<title>询盘管理</title>
<style> button{ padding:5px 15px;}</style>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
  <tr>
    <td height="18" style="border-bottom:2px solid #00c0ef; padding-bottom:5px;"><div align="center"><font color="#3c8dbc" style="font-size:16px;">询盘管理</font></div>
				</td>
  </tr>
  <tr>
    <td height="213" valign="top"><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 = 10;}  */
	if($_SESSION['pagenum']>0)//默认20条每页，选择之后每页显示选择的数量
	{	
		$PageSize = $_SESSION['pagenum'];
	}
	else
	{	$PageSize = $usersNum;}
	
	
	// 获取总数据量
	/********************************************************************************/
	
	$sql="select * from ls_pro_feedback ";
	if($searchproductName!="")
		{
			$sql.=" where enable = 1 and requirement like '%".$searchproductName."%' or name like '%".$searchproductName."%' or tel like '%".$searchproductName."%' or company like '%".$searchproductName."%' or email like '%".$searchproductName."%' ".$wherestr1." and cateNameID = ".$selectcate;
			$ls_msg="包含".$searchproductName."的信息";
		}
	else
	{
		if( $lsc=="type" )
		{
			$sql.=$addsearchstr.$wherestr1." and cateNameID = ".$selectcate;
		}
		else
		{
			if($selectcate != NULL){
				$sql.="where enable = 1"." and cateNameID = ".$selectcate;
			}else{
				$sql.="where enable = 1" ;
			}
		}
	}
	//echo $sql;
	$result=$opendb->query($sql);
	
	/********************************************************************************/
	// 获取总数据量
	
	$row = mysqli_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="98%" align="center">
          <tr>
            <td width="30%">提示：<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"/>
              <button  type="submit"  value="查询" />查询</button>
              </span></td>
            <td width="7%" align="left"><span style="padding-left:6px;"><a href="?lsc=all">全部</a></span></td>
            <td width="19%" align="center" style="padding-left:6px;"><div align="">到
                <input name="gopage" type="text" size="3"/>
                页
                <button type="submit" name="Submit" value="GO" />GO</button>
              </div></td>
            <td width="8%" align="left">共 <b>
              <?=$row?>
              </b> 条</td>
            <td width="7%" align="left"><a href="managefunctioncate.php?functionName=询盘分类" target="right">询盘分类</a></td>
            <td width="7%" align="left">&nbsp;</td>
          </tr>
        </table>
      </form>
      <table border="0" width="98%" align="center">
        <tr>
          <td><?php                if($selectcate=="")
				{echo "<a href='?selectcate=".$selectcate."'><span style=\"color:#930\" >全部</span></a> | ";}
				else
				{echo "<a href='?selectcate='><span style=\"\" >全部</span></a> | ";}
				if($selectcate=='0'){
					echo "<a href='?selectcate=0'><span style=\"color:#930\" >产品</span></a> | ";
				}else{
					echo "<a href='?selectcate=0'>产品</a> | ";
				}
                while($news_rows2=mysqli_fetch_assoc($download_query))
                {
                    if($selectcate==$news_rows2['ID'])
                    {echo "<a href='?selectcate=".$news_rows2['ID']."'><span style=\"color:#930\" >".$news_rows2['cateName']."</span></a> | ";}
                    else
                    {echo "<a href='?selectcate=".$news_rows2['ID']."'>".$news_rows2['cateName']."</a> | ";}
                }
              ?></td>
        </tr>

      </table>
        <form name="del" method="Post" action="delall.php" onSubmit="return ConfirmDel();">
      
      <table width="98%" border="0" align="center" cellpadding="2" cellspacing="4" style="background-color: #f0f0ee;">
        <tr bgcolor="#f0f0ee">
          <td width="3%" align="center" >序</td>
          <td height="30%" colspan="2" align="center">反馈信息</td>
          <td width="6%" height="38" align="center">姓名</td>
         <!-- <td width="6%" height="38" align="center">公司</td>-->
          <td width="10%" height="38" align="center">电话/传真</td>
          <td width="10%" height="38" align="center">邮箱</td>
        <!--  <td width="9%" height="38" align="center">地址</td>-->
          <!--<td width="9%" height="38" align="center">网址</td>-->
          <td width="9%" height="38" align="center">国家 IP</td>
          <td width="4%" height="38" align="center">时间</td>
         <!-- <td width="5%" height="38" align="center">询盘产品</td>-->
          <td width="5%" height="38" align="center">类型</td>
          <td width="4%" 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=mysqli_fetch_assoc($user_query))
					  {
					  ?>
        <tbody id='ZH_<?=$user_rows['ID']?>'>
          <tr bgcolor='#f4f4f4' onmouseover="this.style.backgroundColor='#e5e5e5'" onmouseout="this.style.backgroundColor='#f4f4f4'" >
            <td height='38' align='center' valign="middle"   onclick=""><?=$user_rows['ID']?>
              <br />
              <input name='select_id<?=$i?>' type='checkbox'   id="select_id<?=$i?>" value='<?=$user_rows['ID']?>'> 
              </td>
            <td colspan="2" title='单击展开' onclick="javascript:secBoard(<?=$user_rows['ID']?>)"><div style="width:96%; height:56px; overflow:hidden; white-space:warp; text-overflow:ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;   padding:6px 2px 6px 2px">
                <?=$user_rows['requirement'] ?>
              </div></td>
            <td align="center" onclick="javascript:secBoard(<?=$user_rows['ID']?>)" title='单击展开'><?=trim($user_rows['name'])?></td>
           <!-- <td align="center" onclick="javascript:secBoard(<?=$user_rows['ID']?>)" title='单击展开'><?=trim($user_rows['company'])?></td>-->
            <td align="center"><?=$user_rows['tel']?>
              <?php if($user_rows['fax'] != null) echo "/ ".$user_rows['fax'];?></td>
            <td align="center"><a href="mailto:<?=$user_rows['email']?>" target="_blank">
              <?=$user_rows['email']?>
              </a></td>
         <!--   <td><?=$user_rows['address'] ?></td>-->
           
           <!-- <td align="center"><a href="<?=$user_rows['http']?>" target="_blank">
              <?=str_replace("www.","",str_replace("https://","",str_replace("http://","",$user_rows['http'])) )?>
              </a></td>-->
            <td align="center"><?=$user_rows['ip'] ?></td>
            <td align="center"><?=substr($user_rows['date'], 2, -3);?></td>
            <!--<td align="center" valign="middle"><?php
                                $path = explode(",",$user_rows['path']);  //产品路径数组
								$proName = explode(",",$user_rows['proName']);  //产品名称数组
								
								$subject = array();  //产品路径数组与产品名称数组合并为二维数组
								foreach ($path as $k => $v) {
									$temp = array('path'=>$v,'proName'=>$proName[$k]);  
									$subject[] = $temp;  
								}
								
                                foreach($subject as $val){
									
                                    echo "<a href='".$val['path']."' target=\"_blank\">".$val['proName']."</a><br />";
                                }
                                ?></td>-->
            <td align='center'><?=cateName_s($user_rows['cateNameID'])?></td>
            <td align='center'><?php 						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']."&lsc=unenable' onclick='return ConfirmDel();' title='删除'><img src='images/b_drop.png' border='0'></a>";
						 }?></td>
          </tr>
        </tbody>
        <tbody id='Z_<?=$user_rows['ID']?>' style='display:none;'>
          <tr bgcolor='#f4f4f4' onmouseover="this.style.backgroundColor='#e5e5e5'" onmouseout="this.style.backgroundColor='#f4f4f4'" >
            <td height='38' align='center' valign="middle"  title='单击收起' onclick="javascript:secBoard2(<?=$user_rows['ID']?>)"><?=$user_rows['ID']?>
              <a name="f_<?=$user_rows['ID']?>">&nbsp;</a></td>
            <td colspan="2"  title='单击收起' onclick="javascript:secBoard2(<?=$user_rows['ID']?>)"><div>
                <?=$user_rows['requirement'] ?>
              </div></td>
            <td align="center" onclick="javascript:secBoard2(<?=$user_rows['ID']?>)"  title='单击收起'><?=trim($user_rows['name'])?></td>
            <td align="center" onclick="javascript:secBoard2(<?=$user_rows['ID']?>)"  title='单击收起'><?=trim($user_rows['company'])!=""?trim($user_rows['company'])." / ":""?><?=$user_rows['tel']?>
            <?php if($user_rows['fax'] != null) echo "/ ".$user_rows['fax'];?></td>
            <td align="center"><a href="mailto:<?=$user_rows['email']?>" target="_blank">
              <?=$user_rows['email']?>
            </a></td>
            <td align="center"><a href="mailto:<?=$user_rows['email']?>">
              <?=$user_rows['ip'] ?>
            </a></td>
            <td align="center"><?=substr($user_rows['date'], 2, -3);?></td>
            <td align="center"><?=cateName_s($user_rows['cateNameID'])?></td>
            <td align="center"><?php 						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']."&lsc=unenable' onclick='return ConfirmDel();' title='删除'><img src='images/b_drop.png' border='0'></a>";
						 }?></td>
            
          </tr>
        </tbody>
        <?php 						$i++;
					  }
					 ?>
        <tr>
          <td height="30" colspan="2" align="left" bgcolor="#f0f0ee"><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form);" value="checkbox" />
选中所有
  <button name="submitdel" type='submit' value='删除'>删除</button>
  <input name="Action" type="hidden" id="Action" value="ls_feedback" >
   </td>
          <td height="30" colspan="5" align="center" bgcolor="#f0f0ee"><?php echo( $amount>$PageSize?$page_string:""); ?></td>
          <td height="30" colspan="3" align="center" bgcolor="#f0f0ee">  <select style="height: 28px;width: 80px;" name="pagenum1"  onchange="this.form.submit();">
                    <option selected="" value="<?= $PageSize ?>">每页
                    <?= $PageSize ?>
                    </option>
                    <option value="30">每页30</option>
                    <option value="50">每页50</option>
                    <option value="100">每页100</option>
                     <option value="200">每页200</option>
                   <option value="500">每页500</option>
                      <option value="2000">每页2000</option>
               </select></td>
          <td width="0%" height="30" align="center" bgcolor="#f0f0ee">&nbsp;</td>
        </tr>
      </table>
     
 </form>
      </td>
  </tr>
</table>
</body>
</html>