<!--#include virtual="/appDB/db_connection.asp" -->
<!--#include virtual="/appDB/functions.asp" -->
<!--#include virtual="/admin/scripts/admin_functions.asp" -->
<!--#include virtual="/admin/scripts/enc_function.asp" -->
<!--#include virtual="/admin/scripts/adm_inst.asp" -->
<%
IF (checkPermission("parents")="FAILED") THEN
	response.write("You do not have permission to view this page")
	response.end
END IF
StrError = "None"
Function sanitizeN(requestVariable) 
        Set regEx = New RegExp 
        regEx.Global = true 
        regEx.Pattern = "[^0-9]"
        sanitizeN = regEx.Replace(requestVariable, "")
End Function
IF request("cID")<>"" THEN
	strCID=sanitizeRequest("cID","querystring")
	IF IsNumeric(strCID) THEN
		SET rsB = dbCBK.Execute("SELECT `phone`, `mobile` from cbk_customers WHERE `companyID`='"&str_company_id&"' AND `customerID`='"&strCID&"' limit 1")
		IF rsB.EOF THEN
			StrError = "Customer not found"
		END IF
		DO WHILE NOT rsB.EOF
			cphone=rsB("phone")
			cmob=rsB("mobile")
		rsB.MoveNext
		loop
		rsB.Close
		SET rsB = Nothing

		IF StrError = "None" THEN
			IF cphone <> "" THEN
				cphone=sanitizeN(cphone)
			END IF
			IF cmob <> "" THEN
				cmob=sanitizeN(cmob)
			END IF
		END IF
	ELSE
		StrError = "Customer ID Not Numeric"
	END IF
ELSE
	StrError = "Customer ID"
END IF
%>
<div style="width:100%;max-height:300px;overflow-x:hidden;overflow-y:scroll;box-sizing:border-box;padding:10px;">
<table cellpadding="2" cellspacing="0" style="width:100%;" class="drvDataTable">
		<%IF StrError <> "None" THEN%>
		<tr>
			<td>
				<p>No phone numbers found..</p>
				<div class="clear s10 sep"></div>
				<div style="width:50%; margin:0 auto; padding-top:20px;"><div class="adminbutton"><a href="#" class="close" style="width:99%;color:#fff;">close</a></div></div>
			</td>
		</tr>
		<%ELSE%>
			<%IF cphone<>"" THEN%>
				<tr style="background-color:#f8f8f8;">
						<td><div class="adminbutton"><a href="tel:<%=cphone%>" style="width:99%;color:#fff;">Call landline <span style="display:block;font-size:10px;"><%=cphone%></span></a></div></td>
				</tr>
			<%ELSE%>
				<tr style="background-color:#f8f8f8;">
						<td><div class="disabledbutton"><a href="javascript:void(0);" style="width:99%;color:#fff;" title="No landline # on record">Call landline<span style="display:block;font-size:10px;">(landline number required!)</span></a></div></td>
				</tr>
			<%END IF%>
			<%IF cmob<>"" THEN%>
				<tr style="background-color:#f8f8f8;">
						<td><div class="adminbutton"><a href="tel:<%=cmob%>" style="width:99%;color:#fff;">Call mobile <span style="display:block;font-size:10px;"><%=cmob%></span></a></div></td>
				</tr>
			<%ELSE%>
				<tr style="background-color:#f8f8f8;">
						<td><div class="disabledbutton"><a href="javascript:void(0);" style="width:99%;color:#fff;" title="No mobile # on record">Call mobile<span style="display:block;font-size:10px;">(mobile number required!)</span></a></div></td>
				</tr>
			<%END IF%>
		<%END IF%>
</table>
</div>
<script type="text/javascript">
	$('.close').click(function(e) {
			e.preventDefault();
			$('#dialogwrap').dialog('close');
		});
</script>
