<!--#include virtual="/common/lib/dbcon.asp"-->
<!--#include virtual="/common/lib/func.asp"-->
<%
Dim bdm_idx
Dim ST, sql, s_fileds

bdm_idx = InputValue( request("bdm_idx") )
sh_keyword = InputValue( request("sh_keyword") )

Set ST = New SelectTable
If bdm_idx = "0" Then
	bdm_menuname = "그룹미지정"
else
	bdm_menuname = ST.selectQueryColumn( "select bdm_menuname from bd_address where bdm_idx = '" & bdm_idx & "'" )
End if

s_fileds = "adr_idx, adr_name, adr_mobile1, adr_mobile2, adr_mobile3"
If bdm_idx = "0" Then
	where_query = " where adr_m_id = '" & session("ss_m_id") & "' and adr_mobile1 <> '' and adr_mobile2 <> '' and adr_mobile3 <> '' and (bdm_idx = 0 or bdm_idx = '')"
else
	where_query = " where bdm_idx = '" & bdm_idx & "' and adr_m_id = '" & session("ss_m_id") & "' and adr_mobile1 <> '' and adr_mobile2 <> '' and adr_mobile3 <> ''"
End If

If sh_keyword <> "" Then
	where_query = where_query & " and ( adr_name like '%" & sh_keyword & "%' or adr_mobile1 like '%" & sh_keyword & "%' or adr_mobile2 like '%" & sh_keyword & "%' or adr_mobile3 like '%" & sh_keyword & "%' ) "
End if

order_by = " order by adr_name "
sql = "select " & s_fileds & " from bd_address_page " & where_query & order_by

rs = ST.selectQueryTable( sql )
%>
					<table class="table1" summary="주소록">
						<colgroup>
							<col width="10%" />
							<col width="*" />
							<col width="50%" />
						</colgroup>
						<thead>
							<tr>
								<th scope="col"><input type="checkbox" onclick="chkAllByTagName('chk_adr_idx', this.checked);" /></th>
								<th scope="col">이름(분류명)</th>
								<th scope="col">연락처</th>
							</tr>
						</thead>
						<tbody>
<%
If isnull(rs) Then
%>
							<tr>
								<td colspan="3">주소록이 없습니다.</td>
							</tr>
<%
else
	For i=0 To ubound( rs )
		ST.arr2Value( rs(i) )
		adr_mobile = adr_mobile1 & "-" & adr_mobile2 & "-" & adr_mobile3
%>
							<tr>
								<td><input type="checkbox" id="chk_adr_idx_<%=adr_idx%>" name="chk_adr_idx" value="M;<%=adr_name%>;<%=adr_mobile%>" data-mobile="<%=adr_mobile%>" data-count="1" /></td>
								<td><label for="chk_adr_idx_<%=adr_idx%>"><%=adr_name%>(<%=bdm_menuname%>)</label></td>
								<td><label for="chk_adr_idx_<%=adr_idx%>"><%=adr_mobile%></label></td>
							</tr>
<%
	Next
End if
%>
						</tbody>
					</table>