<%
'***********************************************************************
'** Copyright (C) 2001 - 2004 Max Yuan All Rights Reserved
'**
'** By using this program, you are agreeing to the terms of the
'** GNU General Public License.
'**
'** This program is free software; you can redistribute it and/or
'** modify it under the terms of the GNU General Public License
'** as published by the Free Software Foundation; either version 2
'** of the License, or any later version.
'**
'** All copyright notices regarding MaxWebPortal must remain intact
'** in the scripts and in the outputted HTML.
'** The "powered by" text/logo with a link back to 
'** http://www.maxwebportal.com in the footer of the pages MUST
'** remain visible when the pages are viewed on the internet or intranet.
'**
'** Support can be obtained from support forums at:
'** http://www.maxwebportal.com
'**
'** Email: maxwebportal@hotmail.com
'** ICQ: 148111300
'***********************************************************************
%><!-- #INCLUDE FILE="config.asp" -->
<% If Session(strCookieURL & "Approval") = "256697926329" Then %> 
<!-- #INCLUDE FILE="inc_functions.asp" -->
<!-- #INCLUDE FILE="inc_top.asp" -->
<table border="0" width="100%">
  <tr>
    <td width="33%" align="left" nowrap><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
    <img src="icon_folder_open.gif" height=15 width=15 border="0">&nbsp;<a href="default.asp">Home</a><br>
    <img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_folder_open.gif" height=15 width=15 border="0">&nbsp;<a href="admin_home.asp">Admin Section</a><br>
    <img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_folder_open_topic.gif" height=15 width=15 border="0">&nbsp;Events Manager<br>
    </font></td>
  </tr>
</table>
<br>
<%if request.QueryString("mode") = "action" then
fAction = request.form("formAction")
eventId = request.form("eventID")
if trim(eventId) = "" then%>
		<p align="center">
		<font face="<% =strDefaultFontFace %>" size="<% =strHeaderFontSize %>">No Event selected</font></p>
		<meta http-equiv="Refresh" content="2; URL=<% =chkString(Request.ServerVariables("HTTP_REFERER"), "refer") %>">
		<p align="center">
		<font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
		<a href="<% =chkString(Request.ServerVariables("HTTP_REFERER"), "refer") %>">Back</font></a></p>
<%else
	if fAction = "approve" then
       		strSQL = "UPDATE " & strTablePrefix & "EVENTS SET PENDING = 0 WHERE EVENT_ID IN (" & eventId & ")"
		my_Conn.Execute (strSql)
		eMessage = "The selected event(s) have been approved."
	elseif fAction = "delete" then
		strSQL = "DELETE FROM " &strTablePrefix & "EVENTS WHERE EVENT_ID IN (" & eventId & ")"
		my_Conn.Execute (strSql)
		eMessage = "The selected event(s) have been deleted."
	else
		eMessage = "Error"
	end if%>
		<p align="center">
		<font face="<% =strDefaultFontFace %>" size="<% =strHeaderFontSize %>"><% =eMessage %></font></p>
		<meta http-equiv="Refresh" content="2; URL=<% =chkString(Request.ServerVariables("HTTP_REFERER"), "refer") %>">
		<p align="center">
		<font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
		<a href="<% =chkString(Request.ServerVariables("HTTP_REFERER"), "refer") %>">Back</font></a></p>
<%
end if
else
%>
<table border="1" style="border-collapse: collapse" bordercolor="<% =strTableBorderColor %>" width="95%" align="center" cellpadding="0" cellspacing="0">
<td bgColor="<% =strPopUpTableColor %>" width="50%" align="left"><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><b>Events Manager</b></font></td>
<%
strSQL = "SELECT EVENT_ID, DATE_ADDED, START_DATE, END_DATE, EVENT_TITLE, EVENT_DETAILS, PRIVATE, PENDING, ADDED_BY FROM " &strTablePrefix & "EVENTS WHERE PENDING <> 0 ORDER BY EVENT_ID ASC"
	Set rs = Server.CreateObject("ADODB.RecordSet")
	rs.open  strSql, my_conn

if rs.EOF or rs.BOF then%>
  <tr>
    <td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><br>No new events to approve.<br><br></font></td>
  </tr>
<%else%>
<script language="JavaScript" type="text/JavaScript">
<!--
function checkAll(thisForm,elmnt,tf,x) {
	var o = document.forms[thisForm].elements
	if (o){
		for (i=0; i<o.length; i++){
			if (elmnt != ''){
				if ((o[i].type == 'checkbox')&&(o[i].name.indexOf(elmnt+"") != -1)){
					o[i].checked = tf
				}
			}
			else {
				if (o[i].type == 'checkbox'){
					o[i].checked = tf
				}
			}			
		}
	}	
	for (var j = 0; j < document.links.length; j++){
		if ((document.links[j].href.indexOf(thisForm) != -1) && (document.links[j].href.indexOf('checkAll') != -1)){
			if (tf == true){
				document.links[j].href = "javascript:checkAll('"+thisForm+"','"+elmnt+"',false)";
				//document.links[j].innerText = "- all";
			}
			else {
				document.links[j].href = "javascript:checkAll('"+thisForm+"','"+elmnt+"',true)";
				//document.links[j].innerText = "+ all";
			}
		}
	}
}
function approveEvents(){

	document.events.formAction.value='approve'
	document.events.submit();
}
function deleteEvents(){

	document.events.formAction.value='delete'
	document.events.submit();
}

//-->
</script>
  <tr>
    <td><form action="admin_events.asp?mode=action" method="post" name="events">
    <table width="100%" align="center" cellpadding="1" cellspacing="1"border="1" style="border-collapse: collapse" bordercolor="<% =strTableBorderColor %>">
    <tr>
    <td align="center" width="4%" bgcolor="<% =strHeadCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>" color="<% =strHeadFontColor %>"><a href="javascript:checkAll('events','eventID',true)">Select All</a></font></td>
    <td width="6%" bgcolor="<% =strHeadCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><b>Status</b></font></td>
    <td width="50%" bgcolor="<% =strHeadCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><b>Title</b></font></td>
    <td width="10%" bgcolor="<% =strHeadCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><b>Start Date</b></font></td>
    <td width="10%" bgcolor="<% =strHeadCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><b>End Date</b></font></td>
    <td width="20%" bgcolor="<% =strHeadCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><b>Added By</b></font></td>
    </tr>
<%
do while not rs.EOF
	Select Case rs("PENDING")
		Case "1"
			strStatus = "New"
		Case "2"
			strStatus = "Update"
		Case else
			strStatus = "Error"
	End Select
%>
    <tr>
    <td align="center" bgcolor="<% =strForumCellColor %>"><input type="checkbox" name="eventID" value="<% =rs("EVENT_ID") %>"></td>    
    <td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><% =strStatus %></font></td>
    <td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><% =chkString(Rs("EVENT_TITLE"), "display")%></font></td>
    <td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><% =strToDate(Rs("START_DATE")) %></font></td>
    <td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><% =strToDate(Rs("END_DATE"))%></font></td>
    <td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><a href="pop_profile.asp?mode=display&id=<% =rs("ADDED_BY")%>"><% =getMemberName(rs("ADDED_BY"))%></a></font></td>
    </tr>
    <tr>
    <td colspan="6" bgcolor="<% =strAltForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><% =formatStr(rs("Event_Details")) %></font><br><br></td>
    </tr>
<%
	rs.movenext
	loop
%>
    <tr>
    <td colspan="6" bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><b><a href="javascript:approveEvents()">Approve Selected</a>&nbsp;&nbsp;&nbsp;<a href="javascript:deleteEvents()">Delete Selected</a></font></td>
    </tr>
    </table><input type="hidden" name="formAction"></form>
     </td>
  </tr>
<%end if%>
  <tr>
    <td align="center" bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><a href="admin_home.asp">Back to Admin Home</a></font></td>
  </tr>
</table>
<%
rs.Close
set rs = nothing
end if
%>
<!-- #INCLUDE FILE="inc_footer.asp" -->
<% Else %><% Response.Redirect "admin_login.asp" %><% End If %>