<!--#include virtual="/manager/common/file/member_top.asp"-->
<!--#include file="config.asp"-->
<script type="text/javascript" src="/common/js/03member.js"></script>
<%
prepage = Request.ServerVariables("path_info") & "?" & Request.ServerVariables("query_string")
' 테이블 기본 환경설정 ********************************************************************************

table			= "member_view"	' 테이블명
idx_field		= "m_num"		' 기본키
oreder_filed	= "m_num DESC"	' 정렬기준 필드
Query_Fields	= "lvlname, m_num, m_id, m_name, m_lastdate, m_level, m_date, m_g_sms, m_mobile1, m_mobile2, m_mobile3"	' 불러올 필드

v_pagesize		= 20				' 목록개수
v_block			= 10				' 페이지개수
' ****************************************************************************************************



' ---------------조합 쿼리문------------------------------------
v_search = inputvalue(request("p_search"))
v_keyword = inputvalue(request("p_keyword"))
Query_Where = ""	'기본 검색

If v_keyword <> "" then
	Query_Where = Query_Where & " and "&v_search&" like '%"&v_keyword&"%'"
End If
'' 조건 있을때 여기에 계속 추가

If Query_Where<>"" Then
	Query_Where2 = " WHERE " & Mid(Query_Where,5)
End If

Query_OrderBy = " ORDER BY "&oreder_filed

' ---------------------------------------------------------------



' ---------------------전체 레코드 수 뽑기----------------------------------------
sql = "select count("& idx_field &") as "& idx_field &" from "& table & Query_Where2
Set Rs = Dbcon.Execute (sql)
recordcount = rs(0)	'이 전체레코드갯수를 이용해서 페이지갯수를 뽑아 낼것이다.
rs.close : Set rs = nothing
' ---------------------------------------------------------------------------------


v_totalpage	= int((recordcount-1)/v_pagesize)+1		'전체덩어리갯수 
v_page		= request("p_page")
If v_page="" Then
	v_page = 0
Else
	v_page = Int(v_page)
End if

If v_page = "" then
	v_page = 1
ElseIf v_page < 1 then
	v_page = 1
ElseIf v_page > v_totalpage then
	v_page = v_totalpage
End If


' -----------------------------리스트 출력 쿼리문 생성-----------------------------
strSQL = " SELECT TOP "& v_pagesize &" "& Query_Fields &" FROM "& table &" WHERE "& idx_field &" NOT IN "
strSQL = strSQL & " ( SELECT  TOP "& v_pagesize*(v_page-1) &" "& idx_field &" FROM "& table & Query_Where2 & Query_OrderBy &" ) "
strSQL = strSQL & Query_Where &" "& Query_OrderBy 
Set rs = Dbcon.execute(strSQL)
If Not rs.eof Then
	vData = rs.getrows()
	vCnt = UBound(vData,2)
Else
	vCnt = -1
End If
rs.close : Set rs = Nothing
' ---------------------------------------------------------------------------------



%>

<script type="text/javascript">
//<![CDATA[
function smsChange(m_id, m_name, m_num){
	var obj = document.getElementById("sms"+m_num);
	var value = obj.value;
	if(value == ""){alert("충전할 건수를 입력하세요");obj.focus();return;}
	if(confirm(m_name+"님의 남은 sms건수에 "+value+"건이 더해집니다.\n\n계속하시겠습니까")){
		location.href="smschange.asp?value="+value+"&m_id="+m_id+"&prepage=<%=server.urlEncode( prepage )%>";
	}else{
		return;
	}

}

//]]>
</script>

<!-- 등록/수정UI -->
<div id="dialog" style="text-align:center;vertical-align:middle;">
	<p id="dialogContent"></p>
</div>
		<!-- 내용영역 -->
		<div id="contents">

			<div id="contents_head"> 
				<div id="contents_title">
					<img src="/manager/img/tit_ic03.gif" width="22" height="21" class="<%=skin%> center" alt="" /> <h1><span>회원 리스트</span></h1>
				</div>
				<div id="location">
					<a href="/manager/" tabindex="<%=getTabIndex()%>">Home</a> &gt; <a href="/manager/content/03member/list.asp" tabindex="<%=getTabIndex()%>">회원관리</a> &gt; <a href="list.asp" class="now" tabindex="<%=getTabIndex()%>">회원 리스트</a>
				</div>
			</div>

			<!-- 내용들어가는곳 -->
			<div id="contents_area">

				

					<h2 class="<%=skin%>">가입된 회원 리스트</h2>


					<div class="write_info">

						<div class="write_form pt7">
							<form id="frm_sch" action="list.asp"  method="post">

							<ul>
							<li class="search"><label for="p_search">회원검색</label> :</li>
							<li><select id="p_search" name="p_search" title="검색형태 선택" tabindex="<%=getTabIndex()%>">
								<option value="m_name" <%if v_search = "m_name" Then response.write "selected='selected'" End if %>>이름</option>
								<option value="m_id" <%if v_search = "m_id" Then response.write "selected='selected'" End If %>>아이디</option>
								<option value="lvlname" <%if v_search = "lvlname" Then response.write "selected='selected'" End if %>>그룹명</option>

								
								<option value="m_date" <%if v_search = "m_date" Then response.write "selected='selected'" End If %>>가입일</option>
							</select></li>
							<li><input type="text" size="54" title="검색어를 입력하세요" id="p_keyword" name="p_keyword" class="input_box input" onfocus="focus_on1_<%=skin%>(this);" onblur="focus_off1(this);" value="<%=v_keyword%>" tabindex="<%=getTabIndex()%>" /></li>
							<li><div id="<%=skin%>_bt"><span class="button"><input type="submit" value="검색" tabindex="<%=getTabIndex()%>"/></span></div></li>
							<li><div id="w01_bt"><span class="button"><input type="button" value="전체보기" onclick="page_go1('list.asp');" tabindex="<%=getTabIndex()%>"/></span></div></li>
							<li><div id="w01_bt"><span class="button"><input type="button" value="엑셀다운로드" onclick="page_go1('excel.asp');" tabindex="<%=getTabIndex()%>"/></span></div></li>
							</ul>

							</form>
						</div>

					</div>

					<div class="list_count" style="height:20px">
						<div id="<%=skin%>_bt" class="list_left">
							<span class="button"><input type="button" value="신규회원생성" onclick="dialog_open('신규회원생성', 'write_ui.asp', '');" /></span>
						</div>
						전체 <strong><%=recordcount%></strong>개 (페이지 <strong class="orange"><%=v_page%></strong>/<%=v_totalpage%>)
					</div>


				<form id= "frm_list" action=""  method='post'>
					<div>
						
						<input type="hidden" name="status" />
						<input type="hidden" name="m_level" />
						<input type="hidden" name="m_num" />
						<input type="hidden" id="chk_all" name="chk_all" />
						
					</div>


					<fieldset>
						<legend>회원관리 수정/삭제/보기</legend>
						<table cellspacing="0" class="bbs_<%=skin%>" summary="사이트의 회원을 관리합니다.">
						<caption>회원관리 서식</caption>
						<colgroup>
						<col width="40" />
						<col width="50" />
						<col />
						<col />
						<col width="80" />
						<col width="80" />
						<col />
						<col width="130" />
						<col width="40" />
						<col width="40" />
						<col width="40" />
						</colgroup>

						<thead>
						<tr>
							<th scope="col">선택</th>
							<th scope="col">번호</th>
							<th scope="col">아이디</th>
							<th scope="col">이름</th>
							<th scope="col">최근접속일</th>
							<th scope="col">가입일</th>
							<th scope="col">그룹</th>
							<th scope="col">sms남은건|충전</th>
							<th scope="col">충전<br />내역</th>
							<th scope="col">수정</th>
							<th scope="col">삭제</th>
						</tr>
						</thead>

						<tbody>

<%
If vCnt > -1 then        ' ------ 내용이 있으면 리스트 출력

	If v_page = 1 then
		num = recordcount
	else
		num = recordcount - ((v_page - 1) * v_pagesize)
	End If


	For i=0 To vCnt

		Call arr2Value(Query_Fields, "vData", i)


%>

						<tr>
							<td scope="row" class="center"><input type="checkbox" name="chk" value="<%=m_num%>" title="해당 회원 선택" tabindex="<%=getTabIndex()%>" /></td>
							<td scope="row" class="center"><%=num%></td>
							<td scope="row" class="center"><%=m_id%></td>
							<td scope="row" class="center"><%=m_name%><br />(<%=m_mobile1&m_mobile2&m_mobile3%>)</td>
							<td scope="row" class="center"><%=left(m_lastdate,10)%></td>
							<td scope="row" class="center"><%=left(m_date,10)%></td>
							<td scope="row" class="center"><%=lvlname%></td>
							<!--td scope="row" class="center"><%=m_div_name%></td-->
							<td scope="row" style="text-align:right;">
								<%=m_g_sms%>&nbsp;<b>|</b>&nbsp;<input type="text" size="3" id="sms<%=m_num%>" name="sms<%=m_num%>" value="" class="input_box" maxlength="5" onfocus="focus_on1_<%=skin%>(this);" onblur="focus_off1(this);" style="width:30px;text-align:right;" />
								<a href="javascript:smsChange('<%=m_id%>','<%=m_name%>', '<%=m_num%>')">[충전]</a>

							</td>
							<td scope="row" class="center"><input type="button" value="보기" class="ct_bt01" onclick="location.href='change_log.asp?p_search=m_id&p_keyword=<%=server.urlencode( m_id )%>';" tabindex="<%=getTabIndex()%>" /></td>
							<td scope="row" class="center"><input type="button" value="수정" class="ct_bt01" onclick="dialog_open('수정', 'write_ui.asp?m_num=<%=m_num%>&amp;<%=page_info%>', '');" tabindex="<%=getTabIndex()%>" /></td>
							<td scope="row" class="center"><input type="button" value="삭제" class="ct_bt01" onclick="d_chk('delete_ok.asp?m_num=<%=m_num%>&amp;<%=page_info%>');" tabindex="<%=getTabIndex()%>" /></td>
						</tr>

<%
		num = num - 1
	next


else ' 게시할 목록이 없다면
%>

						<tr>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<!--td scope="row" class="center"></td-->
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
						</tr>
						
<%
End if
%>
						</tbody>
						</table>
					</fieldset>

					<div class="contoll_box2">
						<ul>
						<li><img src="/manager/img/line01.gif" width="36" height="21" alt="" /></li>
						<li class="pt7"><div class="bt01"><a href="javascript:checkAll();" tabindex="<%=getTabIndex()%>"><span>전체 선택/해제</span></a></div><div class="bt01"><a href="javascript:delete2();" tabindex="<%=getTabIndex()%>"><span>선택 회원삭제</span></a></div></li>
						<li class="pt7 pl4"><span class="gray">|</span> &nbsp;선택한 회원을 
								<select id="tot_level_chk" name="tot_m_level" title="선택한 회원그룹 선택" tabindex="<%=getTabIndex()%>">
									
									<%
										' 회원권한 부분
										R_Fields_mg = "g_num, g_menuname"
										sql2 = "Select "&R_Fields_mg&" from member_group where g_chk='Y' order by g_code "
										Set Rs = Dbcon.Execute (sql2)

										Do While Not rs.eof											
									%>
										<option value="<%=rs("g_num")%>" ><%=rs("g_menuname")%></option>
									<%
											rs.movenext
										Loop
										rs.close : Set rs = nothing
									%>
								
								</select>으로
						</li>
						<li class="pt7 pl2"><div class="bt01"><a href="javascript:tot_levelchage('<%=page_info%>');" tabindex="<%=getTabIndex()%>"><span>변경</span></a></div></li>
						</ul>
					</div>
					

					<!-- 페이징 -->
					<div class="paginate">
						<%page("list.asp")%>
					</div>
					<!-- //페이징 -->


				</form>

			</div>
			<!-- 내용들어가는곳 -->

		</div>
		<!-- //내용영역 -->


<!--#include virtual="/manager/common/file/sub_bottom.asp"-->
