<?php

	include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
	include $_SERVER['DOCUMENT_ROOT'].ADMIN_PATH.'common/auth_chk.php';
	$PageNo =$_REQUEST['pageno'];
	if (empty($PageNo)) {$PageNo=1;}else{$PageNo=$PageNo;}
	$PageSize=10; //목록개수설정
	$pagestartpoint=($PageNo-1)*$PageSize;
	$sql = "where ds_delind='N'";

	if($searchword != ""){
		if($searchtype=="" || $searchtype==null){
			$sql = $sql. "	and (nm_name like '$searchword%' or cd_userid like '$searchword%') ";
		}else{
			$sql = $sql. "	and $searchtype like '$searchword%'";
		}
	}
	$totalrows = @mysql_result(mysql_query("select count(*) from admin_info $sql"),0,0);

?>
<? include("../header.php") ?>
<? include("../top_menu.php") ?>
<? include("../left_menu.php") ?>

    <h2>관리자 리스트</h2>
	<form id="frmSearch" name="frmSearch" method="post" action="<?=ADMIN_PATH?>admin/admin_list.php">
      <p class="search">검색조건 <span>
        <select name="" style="width:100px">
			<option value="">전체</option>
			<option value="cd_userid" <? if($searchtype =="cd_userid"){?>selected<?}?>>아이디</option>
			<option value="nm_name" <? if($searchtype =="nm_name"){?>selected<?}?>>이름</option>
        </select>
        <input id="searchword" name="searchword" type="text" style="width:250px" value="<?=$searchword?>">
        <span class="btn_search" onclick="fnSearch();">검색</span> </span> </p>
    </form>
    <table class="tbl_list">
      <tr>
        <th>No</th>
        <th>아이디</th>
        <th>이름</th>
        <th>연락처</th>
        <th>이메일</th>
        <th>등록일</th>
      </tr>
<?
		if($totalrows>0) {

			$r = mysql_query("SELECT * FROM admin_info  $sql ORDER BY cd_seq desc  LIMIT $pagestartpoint,$PageSize");
			$i=1;
			while($col = mysql_fetch_array($r)) { 
?>
				<tr onclick="location.href='./admin_view.php?cd_userid=<?=$col[cd_userid]?>&PageNo=<?=$PageNo?>';" style="cursor: pointer; cursor: hand;">
					<td><?=$i?></td>
					<td><?=$col[cd_userid]?></td>
					<td><?=$col[nm_name]?></td>
					<td><?=$col[nm_info1]?></td>
					<td><?=$col[nm_info3]?></td>
					<td><?=$col[dt_insert]?></td>
				</tr>
<?
				$i++;
			}
		}else{
?>
				<tr>
					<td align="center" bgcolor="#FFFFFF" colspan="6">데이터가 존재 하지 않습니다.</td>
				</tr>
<?
		}
?>
    </table>
    
    
    <table width="100%" height="45" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center" valign="middle">
		<?
				$url = "./admin_list.php?searchtype=$searchtype&searchword=$searchword";
				ListPg1($url ,$PageNo,$PageSize,10,$totalrows,$leftboard[1],$rootpath);
		?>
		</td>
	</tr>
</table>
    
    
    <p class="btn"><span class="btn_ok" onclick="location.replace('./admin_write.php');">신규등록</span></p>

<script language="javascript" type="text/javascript">
	function fnSearch(){
		if($("#searchtype").val()!="" && $("#searchword").val()==""){
			alert("검색어를 입력하세요");
			return false;
		}
		$("#frmSearch").submit();
	}
</script>
<? include("../bottom_menu.php") ?>
<? include("../footer.php") ?>
<?
mysql_close($connect);
?>
