<?php

/*
*	Copyright VeryIDE,2007-2010
*	http://www.veryide.com/
*
*	$Id: ,v1 10:39 2008-7-27 Leilei $
*/

require("../../include/header.php");
html_start("会员列表 - VeryIDE");
?>

<!--body start-->
	<?php

	//module
	require("naver.php");

	$q = GetQuery("q");
	$s = GetQuery("s");
	$base = $_GET["b"];
	
	$list = GetQuery("list");
	$action = GetQuery("action");
	
	//mysql open
	reader_mysql();

	if ($action){
	
		switch($action){
			//删除
			case "delete":
			
				//检查权限
				checker_func("mod-member-data-del");		
			
				//删除数据
				mysql_query("delete from ".VI_DBMODPRE."values where id in(".$list.")");
				
				$result = mysql_affected_rows($mysql);
				
				//更新统计
				mysql_query("update ".VI_DBMODPRE."forms set stat=stat-".$result." where id = ".$fid);				
				
				reader_redirect($appid.".value.php?fid=".$fid,"用户数据删除成功!");
				
			break;
		}
	}
    ?>
    
    <div id="search">
    <!--用于动作处理_开始-->
    <form name="formPost" id="formPost" method="post" action="?">
        <input name="list" id="list" type="hidden" value="">
        <input name="action" id="action" type="hidden" value="" />
        <input name="url" id="url" type="hidden" value="" />
        <input name="status" id="status" type="hidden" value="" />
        <input name="fid" value="<?php echo $fid;?>" type="hidden" />
    </form>
     <!--用于动作处理_结束-->
    
    <form name="formSearch" id="formSearch" method="get" action="?">
    
    	<span class="action">
			<button class="button" onclick="toggle('formAdv');" type="button">高级选项</button>
            <?php 
			if( $Group["mod-member-data-dow"] == "Y" ){
			?>
			<button class="cancel" type="button" onclick="location.href=location.href.replace('value.php','report.php');">下载数据</button>
            <?php
			}
			?>
        </span>
    
        <select name="s" id="s">
            <option value="id" checked> I D</option>
            <option value="fid"> FID</option>
            <option value="account"> 用户名称</option>
            <option value="name" checked> 真实姓名</option>
        </select>
        <input name="q" type="text" class="text" id="q" value="<?php echo $key;?>" />
        
        <button class="go" type="submit"></button>
        
        <div id="formAdv" class="advanced" style="display:none;">        
			<?php
            foreach ($Modules["member"]["fieds"] as $fied => $name){
                echo '<label><input name="b['.$fied.']" value="1" type="checkbox" class="checkbox" '.($base[$fied]?' checked="checked"':'').' onchange="$(\'formSearch\').submit();" onclick="$(\'formSearch\').submit();" /> '.$name.'</label>';
            }
            ?>        
        </div>
       
    </form>
    </div>
    
    <script type="text/javascript">
         Mo("#s").value("<?php echo $s;?>");
		
		<?php
		if( is_array($base) ){
			echo "Mo('#formAdv').toggle();";
		}
		?>
    </script>

    <?php
	
    $sql="SELECT * FROM ".VI_DBMODPRE."values where 1=1 ";
    if ($q && $s){
        $sql.=" and  ".$s." like '%".$q."%'";
    }
    
    //排序
    $sql.=" order BY id desc";
	
	//echo $sql;
    
    //查询数据库_总记录数
    $row_count = $db -> getValue( str_replace("*","count(id)",$sql) );   

    
    $Project["queries"]++;

    //分页参数
    $page=GetPage("page");
    $page_start=$Global["pagesize"]*($page-1);
    $sql=$sql." limit $page_start,".$Global["pagesize"];	
    
    //分页链接
    $url="?q=".$q."&s=".$s."&page=";
    
    $result=mysql_query($sql,$mysql);
	
    $Project["queries"]++;
    ?>
    
    <table width="100%" border="0" cellpadding="1" cellspacing="1" id="table" class="table">
		<?php
		if( mysql_num_rows($result)> $Global["pagesize"]/2 ){
		?>
        <tr class="thead">
            <td colspan="7" class="first"><?php echo $Modules[$appid]["tool"];?></td>
        </tr>
      	<?php
		}
		?>
      
        <tr class="title" id="thead">
            <td width="30"></td>
            <td width="100">用户名</td>
            <td width="80">活动类型</td>
            <td width="200">活动名称</td>
            <td>提交内容</td>
            <td>提交时间</td>
            <td width="60">IP</td>
        </tr>
      
    <?php
    //VeryIDE 绝对路径
    $uripath=uripath();
    
    while($row=mysql_fetch_assoc($result)){
        
        ////配置
        $config = fix_json( $row["config"] );
		
		//加载缓存
		loader_cache($appid,"forms.".$row["fid"]);
		
		//加载配置		
		$cfg = $VICACHE["sys.module"][$VICACHE["mod.forms"]["appid"]]["config"];
		
		if( $cfg ){
			require($Project["module"].$cfg);
		}
        ?>
          <tr class="line" pid="<?php echo $row["id"];?>">
            <td title="<?php echo $row["id"];?>">
                <input name="id" type="checkbox" class="checkbox" id="id-<?php echo $row["id"];?>" value="<?php echo $row["id"];?>">
            </td>
            <td title='<?php echo $row["name"];?>'>
                <a href="<?php echo "?s=id&q=".$row["id"];?>"><?php echo format_substr($row["account"],30,"...");?></a>
                <?php
				if( $row["uid"] ){
					echo loader_image("card.png","个人信息","","parent.Mo.Window('dialog','用户个人信息' ,'".$appid.".profile.php?uid=".$row["uid"]."' ,'850','80%',{}); return false;");
				}
				?>
            </td>
            <td>
            <?php
			 echo $Modules[$VICACHE["mod.forms"]["appid"]]["name"];
			?>
            </td>
            <td>
            <a href="<?php echo "?s=fid&q=".$row["fid"];?>">
            <?php
			 echo $VICACHE["mod.forms"]["name"];
			?>
            </a>
            </td>
            <td>
            <?php
			 echo $row["config"];
			?>
            </td>
            <td title="<?php echo date("Y/m/d H:i:s",$row["dateline"]);?>">
                <?php
                echo '<span class="text-yes">'.date("Y/m/d",$row["dateline"]).'</span>';
                ?>
            </td>
            <td>
                <?php
                echo $row["ip"];
                ?>
            </td>
            </tr>
        <?php
        }
        ?>
        
        <tr class="tfoot">
            <td colspan="5" class="first">
                <?php echo $Modules[$appid]["tool"];?>
            </td>
            <td colspan="2">
                
            </td>
        </tr>
    </table>
    <?php
  
    //mysql close
    reader_mysql(true);
    
    ?>
    
    <!--up-->
    
    <div id="saving">
		<?php
            echo GetPageLink($page,$row_count,$Global["pagesize"],$url,"page");
        ?>
    </div>
    
<!--body end-->

<?php html_close();?>