<?php 
session_start(); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?
	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');
	
	$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=mysql_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">
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
	</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 = 10;}
	
	// 获取总数据量
	/********************************************************************************/
	
	$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 = 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="6%" align="right"><span style="padding-left:6px;"><a href="?lsc=all">全部</a></span></td>
							<td width="21%" align="right" 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="9%" align="right">共 <b>
                              <?=$row?>
                            </b> 条信息</td>
                        </tr>
			   </table>
	    </form>
        <table border="0" width="100%" align="center">
            <tr>
              <td>
              <!--
               <?
               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=mysql_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>
		<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
        <tr bgcolor="#B9DAFF">
          <td width="25" align="center" >序号</td> 
						<td height="38" colspan="9" align="center">询盘信息</td>
                        <td width="47" height="38" align="center">类别</td>
                       <td width="26" 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='center' height='38' ><?=$user_rows['ID']?></td>
							<td colspan="9" ><a name="f_<?=$user_rows['ID']?>">&nbsp;</a>
								<strong>姓名：</strong><?=$user_rows['name'] ?> &nbsp;;&nbsp; <!--<strong>公司名称：</strong><?=trim($user_rows['company'])?> &nbsp;;&nbsp; --><strong>电话：</strong> <?=$user_rows['tel']?><? if($user_rows['fax'] != null) echo "， &nbsp; 传真：".$user_rows['fax'];?>&nbsp;;&nbsp; <strong>E-mail:</strong><a href="mailto:<?=$user_rows['email']?>"><?=$user_rows['email']?></a>，&nbsp;;&nbsp; <!--<strong>网址：</strong><a href="http://<?=$user_rows['http']?>" target="_blank"><?=$user_rows['http']?></a>--><br />
								<!--<strong>地址：</strong><?=trim($user_rows['address'])?>-->
								<p style="font-size:13px; width:1000px;"><strong>信息：</strong>
								  <?=$user_rows['requirement'] ?>
                                </p>
                                <span>
                                <?php
                                $array = explode(", ",$user_rows['path']);
                                foreach($array as $url){
                                    echo "<a href='".$url."' target=\"_blank\">".$url."</a><br />";
                                }
                                ?>
                                </span>
								<p style="color:#999; font-style:italic;">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>
                            <td align='center'><?=cateName_s($user_rows['cateNameID'])?></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']."&lsc=unenable' onclick='return ConfirmDel();' title='删除'><img src='images/b_drop.png' border='0'></a>";
						 }?></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>