<?
ob_start();
session_start();
if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
 include("../include/db.inc.php");
 include("../include/pager.php"); 
 include("../include/bit_functions.inc.php");
 include("../include/mail.php");
   $db1=new db;
   $db1->open();
    mysql_query("SET NAMES 'utf8'");
   $letter=$_GET['letter'];
 		
 		if(isset($_POST['send']) && is_array($_POST['chkbx']))
		{
		$newsletter=mysql_query("select subject,description from t123go_newsletter where nid='".$letter."'");
		$newsletter=mysql_fetch_array($newsletter);
		$subject=$newsletter['subject'];
		$desc=$newsletter['description'];		
		
		foreach($_POST['chkbx'] as $sendid)
			{	
			
			send_newsletter($subject,$desc,$sendid);			
			}
		
		header("location:newsletter_list.php?sendnews=".base64_encode($sub));
		
		}  
   
  $sel_query=mysql_query(dopaging("select id,uname,email from user where email!=''",20)) or die(mysql_error());
  $count=mysql_num_rows($sel_query);
   
?>
<!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>123gewon | Admin Controls</title>
<link href="index.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../js/common.js"></script>
<SCRIPT language="javascript">

function checkAll(check1,total) 
{ 
var len=document.form1.chkbx.length;

 if(document.form1.select2.value=='all')
 {
   for (var m=0;m<len;m++) 
    {   
		document.form1.chkbx[m].checked=true;     
     }   
 }
 else
 {
 	for (n=0;n<len;n++) 
	{    
		document.form1.chkbx[n].checked=false;       
     } 
 }
}
</SCRIPT>
<style type="text/css">
<!--
.style1 {color: #093A9C}
.style2 {color: #FE6905}
-->
</style>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
a {
	font-size: 11px;
	color: #003366;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #003366;
}
a:hover {
	text-decoration: underline;
	color: #003366;
}
a:active {
	text-decoration: none;
	color: #333333;
}
-->
</style>
</head>

<body bgcolor="#ffffff">
<div class="admin_wrapper">
<div class="logo_show"><? include("minorlogout.php");?></div>
<div style="float:left; width:200px">
<div class="topg_links_show"><? include("left.php");	?></div>
<div class="top_links_show"><? include("belowleft1.php");	?></div></div>
<div style="float:left; width:800px">
<div class="maximum">

<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::center starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<div style="margin-top:5px; border-collapse:collapse; border-color:#404193">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" >
  <tr height="417">
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::left starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->   
    
	<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::left ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->    
<td width="84%" bgcolor="#FFFFFF" valign="top">
	  <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
  <tr> 
    <td width="15" valign="top">&nbsp;</td>
          <td valign="top"><br><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                  
                <td background="img/bg01.gif"><strong>USER LIST </strong></td>
          <td width="35"><img src="img/04.gif" width="35" height="23"></td>
        </tr>
      </table>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="22" height="185" valign="top" background="img/tbl-left04.gif">
          <img border='0' src="img/tbl-left04.gif" width="22" height="13"></td>
          <td valign="top" align="center"><br>		  		  		             
                   <form action="" method="post" enctype="multipart/form-data" name="form1">
                    <table width="100%" border="0" cellspacing="1" cellpadding="1" style="border-color:#FED267">
                      <tr bgcolor="#FED267"> 
					   <td width="6%"  align="center"><strong><font color="#FFFFFF">User ID</font></strong></td>
                        <td width="11%" >&nbsp;&nbsp;<strong><font color="#FFFFFF">Username</font></strong></td>
                        <td width="12%" ><strong><font color="#FFFFFF">Email</font></strong></td>
                        
                       
                        <td width="10%" height="21" align="center"><strong><font color="#FFFFFF">
						Select User :&nbsp;&nbsp;<select style="width:60px" name="select2" class="button1" onChange="checkAll(true,'<?=$count?>');">
				  <option>----</option>
				  <option value="all">All</option>
				  <option value="none" >None</option>
                  </select></font></strong></td>
                      </tr>
					  <?
					  
					   $i=1;
					  
                      while($myrow=mysql_fetch_array($sel_query)){  ?>
                      <tr <? if($i%2==0)echo 'bgcolor="#E6E4E3"';?>> 
					  <td  align="center"><?=$myrow['id'];?></td>
                      <td>&nbsp;&nbsp;
						<?=$myrow['uname'];?></td>
                        <td style="padding-left:5px;"><?=$myrow['email'];?></td>
                        <td ><input type="checkbox" id="chkbx" name="chkbx[]" value="<?=$myrow['id']?>"/>						</td>
                      </tr>
                      
                      <? $i++;
									} if(rightpaging())?>
				<tr><td colspan="2" align=center><br><?=rightpaging()?></td></tr>
                <tr>
                        <td align="right">
                        <input type="submit" name="send" value="SEND" >                        </td>
						<td colspan="2" align="right">
                        <input type="button" name="back" value="Back to List" onClick="window.location.href='newsletter_list.php'" >                        </td>
						</tr>
                    </table>
                  </form>
      </td>
          <td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>
        </tr>
      </table>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
                <td  width="709" align="right" background="img/tbl-bg.gif"></td>
                <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
              </tr>
            </table>
      </td>
  </tr>
  
</table></td></tr>
</table>
</div>


</div></div>
<div class="bottom_links_show"><? include("footer.php");	?></div>
</div>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
</body>
</html>
