 
<!--#include file="includes\Connect.asp"-->
<!--#include file="includes\chklogin.asp"-->

<%
	Dim IsNoRecs
	Dim Rs,icnt
	Function GetSubmitMode()
	  if request.QueryString("ID") <> "" then
		Response.Write "document.thisForm1.action='tradecategory.asp?mode=update&id=" & request.QueryString("ID") & "';"
	  else
		Response.Write "document.thisForm1.action='tradecategory.asp?mode=save';"
	  end if
	End function

    Function GetButton()
		Dim strRet,rs1
		if request.QueryString("Mode") = "add"  then
			strRet = "<input type=submit class=butten value=Save name=btnSave>"
		elseif request.QueryString("Mode") = "edit"  then
			strRet = "<input type=submit class=butten value=Update name=btnSave>"
		end if
		GetButton = strRet
    End Function
 
    Function GetList()
		Dim rs, strRet,strusername
		set rs = Server.CreateObject("Adodb.recordset")
		rs.Open "select Distinct(User_ID_FK) from Tbl_UserPhotos where Approval='A' or (Approval='' or Approval is null)",cn,1,3
	 	if not (rs.eof or rs.bof) then
			while not rs.eof
			  strusername=Cn.execute("select UserName from tbl_user where User_ID_PK="&rs("User_ID_FK")&"")(0)  
			  strRet = strRet & "<tr class=tblContent><td width='470'><a href='photoapproval.asp?Mode=Photodisplay&id="&rs("User_ID_FK")&"'>" & strusername & "</a></td>"  
			  rs.movenext
			wend
		else
			IsNoRecs = True
			strRet = "<tr class=tblContent align=center><td>No Records Found</td></tr>"
		end if
		GetList = strRet
    End function
%>
 <html>
<head>
<title>Web Control Panel - Match - Findyourfate </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="includes/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript">var linkPath="";</script>
<script language="JavaScript" src="includes/scripts.js"></script>
<script language="JavaScript">
function fnNewWindow(x)
{
 	window.open(x,'','width=459 height=362, top=0, left=0, scrollbars=no, resizable=no');
}
function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g, "");}
flg=0;
function fnapproval()
{ 
	for(i=1;i<document.thisForm1.hidcountid.value;i++)
		{		
			if ((eval("document.thisForm1.rdoApproval"+i)[0].checked == true) || (eval("document.thisForm1.rdoApproval"+i)[1].checked == true) )
			{ 
				flg=1;
	 		} 	
	 	}
		if ( flg == 1 )
		{
			document.thisForm1.action="photoapproval.asp?Mode=Approved"
			document.thisForm1.submit();
		}
		else
		{
			alert("Please select approve or reject atleast one photo");
		}
}
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
 <!--Start : Main Table-->
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" align="center">
<tr><td width="100%" height="20" colspan="3" align="center"><img src="images/spacer.gif" border="0" height="20"></td></tr>
<tr>
	<td width="20" height="100%"><img src="images/spacer.gif" border="0" width="20"></td>
	<td width="100%" height="100%" valign="top">
		<table cellpadding="0" cellspacing="0" border="1" width="100%" height="100%" class="tmain" bordercolor="#000000" style="border:thin;">
		<tr>
			<td>
				<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
				<!-- Start : Header  -->
				<tr><td><script language="JavaScript">fnHeader();</script></td></tr>
				<!-- End : Header  -->
				
				<!-- Start : Menu -->
				<tr><td><script language="JavaScript">fnMenu();</script></td></tr>
				<!-- End : Menu -->
				
				<!-- Start : Title -->
				<tr class="titlebg"><td>
					<table cellpadding="0" cellspacing="0" border="0" width="98%" height="22" align="center">
					<tr>
						<td class="title">Welcome <font class="session"><%=session("UID")%></font></td>
						  <td align="right" class="session"><b><%=Session("Msg")%></b></td>
						  <%session("Msg")=""%>
					</tr>
					</table>
				</td></tr>
				<!-- End : Title -->
				
				<tr><td><img src="images/spacer.gif" border="0" width="1" height="1"></td></tr>
				
				<!-- Start : Sub Title -->
				<tr class="subtitlebg"><td>
					<table cellpadding="0" cellspacing="0" border="0" width="98%" height="22" align="center">
					<tr>
						<td class="subtitle">Photo Approval</td>
						<td align="right">
						<%if request.QueryString("id") <> "" then%>
							 <a href="photoapproval.asp">Go Back</a>
						</td>
			 			<%end if%> 
					</tr>
					</table>
				</td></tr>
				<!-- End : Sub Title -->
				
				<tr><td width="100%" height="100%" valign="top" lass="contentbg"><br>
				<!-- Start : Table Of Contents -->
	<form name="thisForm1" method="post">
		  <table cellpadding="4" cellspacing="1" border="0" width="300" align="center" class="tblBorder">
			 
	<%select case request.QueryString("Mode")
	Case "","Approved"%>
		<%
		Set Rs=Server.CreateObject("Adodb.recordset")
	 	Dim sql,id ,sql1
	   			if  (request("rdoApproval1")="1A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=1 and User_ID_FK="&request("hiduserid") & " "
			 		cn.execute sql
	  		 		 sql1= "update Tbl_profiles set PhotoActive=true where User_ID_FK="&request("hiduserid") & " "
			  		cn.execute sql1 		
					end if
	  			if  (request("rdoApproval1")="2A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=2 and User_ID_FK="&request("hiduserid") & " "
			 		Cn.execute sql
		 		 	end if
	 			if  (request("rdoApproval1")="3A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=3 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			  	end if
				if  (request("rdoApproval2")="1A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=1 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			 		cn.execute  "update Tbl_profiles set PhotoActive='true' where User_ID_FK="&request("hiduserid") & " "
			  	end if
	  			if  (request("rdoApproval2")="2A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=2 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			 	end if
	 			if  (request("rdoApproval2")="3A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=3 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			 	end if
				if  (request("rdoApproval3")="1A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=1 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			  		cn.execute  "update Tbl_profiles set PhotoActive='true' where User_ID_FK="&request("hiduserid") & " "
			  	end if
	  			if  (request("rdoApproval3")="2A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=2 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			 	end if
	 			if  (request("rdoApproval3")="3A")	then
					sql= "update Tbl_UserPhotos set Approval='A' where Priority=3 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			 	end if
	 			if  (request("rdoApproval1")="1R")	then
			 		sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=1 and User_ID_FK="&request("hiduserid") & " "
					cn.execute sql
	  	 			cn.execute  "update Tbl_profiles set PhotoActive=False where User_ID_FK="&request("hiduserid") & " "
		  		end if
	  			if  (request("rdoApproval1")="2R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=2 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
		   		 	end if
	 			if  (request("rdoApproval1")="3R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=3 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			  	end if
				if  (request("rdoApproval2")="1R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo=''  where Priority=1 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
		 			cn.execute  "update Tbl_profiles set PhotoActive=False where User_ID_FK="&request("hiduserid") & " "
		 	 	end if
	  			if  (request("rdoApproval2")="2R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=2 and User_ID_FK="&request("hiduserid") & " "
					Cn.execute sql
			  	end if
	 			if  (request("rdoApproval2")="3R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=3 and User_ID_FK="&request("hiduserid") & " "
	 				Cn.execute sql
			 	end if
				if  (request("rdoApproval3")="1R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=1 and User_ID_FK="&request("hiduserid") & " "
	 				Cn.execute sql
		 			cn.execute  "update Tbl_profiles set PhotoActive=False where User_ID_FK="&request("hiduserid") & " "
		 	 	end if
	  			if  (request("rdoApproval3")="2R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=2 and User_ID_FK="&request("hiduserid") & " "
	 				Cn.execute sql
			 	end if
	 			if  (request("rdoApproval3")="3R")	then
					sql= "update Tbl_UserPhotos set Approval='R',photo='' where Priority=3 and User_ID_FK="&request("hiduserid") & " "
	 				Cn.execute sql
			 	end if
				id=request("id")
	  	  		session("Msg")="Photo Approval Updated Successfully"
		 		response.Redirect("photoapproval.asp?Mode=editdel")
%> 	 
<%
   case "","Photodisplay" 	
		Dim intCnt
		set Rs=server.createobject("ADODB.recordset")
		Dim strnull,userid
		strnull=""
	  		userid= request("id")
	  		rs.Open "select * from Tbl_UserPhotos where User_ID_FK="&request("id")&" and (Approval ='A' or (Approval is null or Approval='')) order by priority",Cn,1,3
 		if not Rs.EOF then 
			intCnt = 1
			while not(rs.EOF)
%>
				<tr bgcolor="white">
		 	 		<td align="center"><a href="viewimage.asp?id=<%=userid%>&pid=<%=rs("Priority")%>" target="_blank">
					  	<img width="100" height="100" src="../propics/<%=rs("Photo")%>" border='0' ></a></td>
				 	<td>
					<%
				 	if rs("Approval")="A" then%>
				 	<input type="radio" name="rdoApproval<%=intCnt%>" checked value='<%=rs("Priority")%>A'>Approve	
					<%else%>
				 	<input type="radio" name="rdoApproval<%=intCnt%>"    value='<%=rs("Priority")%>A'>Approve	
				 	<%end if %>
					<%if rs("Approval")="R" then%>
				 	<input type="radio" name="rdoApproval<%=intCnt%>" checked value='<%=rs("Priority")%>R'>Reject	
					<%else%>
				 	<input type="radio" name="rdoApproval<%=intCnt%>"    value='<%=rs("Priority")%>R'>Reject	
				 	<%end if %>
				 	</td>
				</tr>
		 
<%  		intCnt = intCnt + 1 
			rs.MoveNext 
			wend
		end if		
%>
<%if intCnt>0 then %>
	 		<tr bgcolor="#FFFFFF"><td align="center" colspan="3">
			<input type="hidden" value="<%=intCnt%>" name="hidcountid">
			<input type="hidden" value="<%=request("id")%>" name="hiduserid">
	 		<input type='button' name ='upd1' class='butten' value='Update' onClick='fnapproval();'>
		   </td></tr>
	<%else%>
			<tr><td align="center"  bgcolor="#FFFFFF" colspan="3"  > No record(s) Available 
	<%end if
	  cn.close
	%>
 <% case "editdel"%>
	 			<tr>
				<td class="tblHead"><b>User Name</b></td>
				</tr>
  		<%=GetList()%> 
  			<tr><td bgcolor="#FFFFFF"  colspan="3" align="center" height="30"><%=GetButton()%></td></tr>
		
<% 
  end select
%>
			 	  </table>
				</form>
			 	<!-- End : Table Of Contents -->
				</td></tr>
				</table>
			
			</td>
		</tr>
		</table>
	</td>
	<td width="20" height="100%"><img src="images/spacer.gif" border="0" width="20"></td>
</tr>
<tr><td width="100%" height="20" colspan="3" align="center"><img src="images/spacer.gif" border="0" height="20"></td></tr>
</table>
<!--		End : Main Table		-->
</body>
</html>
