<?
require_once "configure.php";

if(!isset($_SESSION["egoUserName"])){
	print("<script type='text/javascript'>location.href='signin.php'</script>");
}

if($_POST["btnSubmit"]){
	if(!$uid){
		print("<script type='text/javascript'>alert('Please select account to active.')</script>");
	}else{
		
		for($i=0; $i< count($uid); $i++)
		{
			$sql="update user set approval='Yes' where id='".$uid[$i]."'";
			@mysql_query($sql) or die(mysql_error());			
			
		    $sql = "SELECT * from user where approval='No' and type='User'";
			$result =mysql_query($sql)or die(mysql_error());
			while($myrow=MySQL_fetch_array($result))
			{
		
				$subject="Your sgc forum is active now";	
				$msg="Dear ".$myrow["name"].",
				
				Your sgc forum account have been actived. You can start to create a discussion or post comment.
				
				Best Regard,
				
				SGC Administrator
				
				 ";
				
				mail($myrow["email"],$subject,$msg,'From:hr@sepanggoldcoast.com');	
		
			}
		}
	}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=TITLE;?></title>
<link rel="stylesheet" type="text/css" href="style.css" >
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}
//  End -->
</script>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="46" bgcolor="#38abe3">
      <? require_once "header.php"; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>
    
    <form name="form" method="post" action="<?=$PHP_SELF;?>">
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="35" class="signin">Account Activation</td>
          </tr>
           
        </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td bgcolor="#ccc"><table width="100%" border="0" cellpadding="1" cellspacing="1">
                  <tr>
                    <td width="4%" height="40" bgcolor="#cfecff" class="text">No.</td>
                    <td width="23%" height="40" bgcolor="#cfecff" class="text">Email</td>
                    <td width="32%" bgcolor="#cfecff" class="text">Full Name </td>
                    <td width="15%" bgcolor="#cfecff" class="text">NRIC No.</td>
                    <td width="15%" bgcolor="#cfecff" class="text">Mobile No.</td>
                    <td width="11%" align="center" bgcolor="#cfecff" class="text"><input type="button" name="CheckAll" value="Check All"
onclick="checkAll(document.form.uid)" />
                      <br />
                      <input type="button" name="UnCheckAll" value="Uncheck All"
onclick="uncheckAll(document.form.uid)" />
                      &nbsp; </td>
                  </tr>
                  <?
				  $i=0;
  		    $sql = "SELECT * from user where approval='No' and type='User'";
			$result =mysql_query($sql)or die(mysql_error());
			while($myrow=MySQL_fetch_array($result))
			{
				$id=$myrow["id"];
				$i++;
				echo "<tr bgcolor='#e3f4ff'>";
				echo "<td height='25' align='center'>".$i."</td>";
				echo "<td class='text'>".$myrow["email"]."</td>";
				echo "<td class='text'>".$myrow["name"]."</td>";
				echo "<td class='text'>".$myrow["ic"]."</td>";				
				echo "<td class='text'>".$myrow["mobile"]."</td>";				
				echo "<td align='center'><input type='checkbox' name='uid[]' id='uid' value='$id'></td>";				
				echo "</tr>";
			}
		  
		  ?>
                
                </table></td>
              </tr>
            </table>
       </td>
      </tr>
      <tr>
        <td align="right">
          <input type="submit" name="btnSubmit" id="button" value="Make Activation" />
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><a href="http://egenos.com" target="_blank">Powered by eGen online solution</a></td>
      </tr>
    </table> </form></td>
  </tr>
</table>
</body>
</html>
