<? ob_start();
session_start();
require_once("../dbconnect.php");
?>
<!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=iso-8859-1" />
<? require_once("title.php"); ?>

<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<link href="../pagecss.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="ajaxvalid.js"></script>
<style type="text/css">
<!--
.style2 {
	color: #21262A;
	font-size: 12px;
}
-->
</style>


</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><? require_once("header.php"); ?></td>
          </tr>
		    <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><table width="79%" border="0" align="left" cellpadding="0" cellspacing="0">
              <tbody>
                <tr>
                  <td class="index_text" align="center" valign="top" width="271">LEGEND: </td>
                  <?php /*?><td class="index_text" align="center" valign="top" width="80">Status OFF <br />
                            <img src="images/icon_red_on.gif" alt="Status - Disabled" title=" Status - Disabled " border="0" /></td>
                        <td class="index_text" align="center" valign="top" width="86">Status ON <br />
                            <img src="images/icon_green_on.gif" alt="Status - Enabled" title=" Status - Enabled " border="0" /></td><?php */?>
                  <td class="index_text" align="center" valign="top" width="177"> Email/Newsletter Status ON <br />
                    <img src="images/publish_g.png" border="0" />					  </td>
                  <td class="index_text" align="center" valign="top" width="325"> Email/Newsletter Status OFF<br />
                    <img src="images/publish_r.png" border="0" />					  </td>
                  <!--     <td class="index_text" align="center" valign="top" width="133">Meta Tags Defined:<br />
Yes&nbsp;No<br />
<img src="images/icon_edit_metatags_on.gif" alt="Meta Tags Defined" title=" Meta Tags Defined " border="0" />&nbsp;<img src="images/icon_edit_metatags_off.gif" alt="Meta Tags Undefined" title=" Meta Tags Undefined " border="0" /></td>-->
                </tr>
              </tbody>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="30" class="cate_pro">Newsletter</td>
                    <td>&nbsp;</td>
                    <td class="index_text" align="right">&nbsp;</td>
                    <td width="20">&nbsp;</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="72%" valign="top" style="padding-right:1px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td height="35" colspan="2"><table border="0" cellpadding="2" cellspacing="0" width="100%">
                          <tr class="dataTableHeadingRow">
                            <td width="73" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent"><u>Id</u></td>
                            <td width="183" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent"><strong>Email Address</strong>&nbsp;&nbsp;&nbsp;</td>
                            <td width="180" align="left" bgcolor="#D7D6CC" class="dataTableHeadingContent">Action&nbsp;</td>
                          </tr>
                          
								<?php
								
								 	 ///*** csv **///
				 $fp = fopen('newsletter.csv','a');
				 $rep="";
				  //fwrite($rep, "\n");
			
				$tbl_name="bulkemail";		//your table name
	// How many adjacent pages should be shown on each side?
	$adjacents = 2;
	
	/* 
	   First get total number of rows in data table. 
	   If you have a WHERE clause in your query, make sure you mirror it here.
	*/
	$query = "SELECT COUNT(*) as num FROM $tbl_name where reguser=0";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages[num];
	
	/* Setup vars for query. */
	$targetpage = "hookmeup.php"; 	//your file name  (the name of this file)
	$limit = 15; 								//how many items to show per page
	$page = $_GET['page'];
	if($page) 
		$start = ($page - 1) * $limit; 			//first item to display on this page
	else
		$start = 0;								//if no page var is given, set start to 0
	
	/* Get data. */
  $sql = "Select * from bulkemail where reguser=0  LIMIT $start, $limit";
	$catres = mysql_query($sql);
	
	/* Setup page vars for display. */
	if ($page == 0) $page = 1;					//if no page var is given, default to 1.
	$prev = $page - 1;							//previous page is page - 1
	$next = $page + 1;							//next page is page + 1
	$lastpage = ceil($total_pages/$limit);		//lastpage is = total pages / items per page, rounded up.
	$lpm1 = $lastpage - 1;						//last page minus 1
	
	/* 
		Now we apply our rules and draw the pagination object. 
		We're actually saving the code to a variable in case we want to draw it more than once.
	*/
	$pagination = "";
	if($lastpage > 1)
	{	
		$pagination .= "<div class=\"pagination\">";
		//previous button
		if ($page > 1) 
			$pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>";
		else
			$pagination.= "<span class=\"disabled\">« previous</span>";	
		
		//pages	
		if ($lastpage < 7 + ($adjacents * 2))	//not enough pages to bother breaking it up
		{	
			for ($counter = 1; $counter <= $lastpage; $counter++)
			{
				if ($counter == $page)
					$pagination.= "<span class=\"current\">$counter</span>";
				else
					$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
			}
		}
		elseif($lastpage > 5 + ($adjacents * 2))	//enough pages to hide some
		{
			//close to beginning; only hide later pages
			if($page < 1 + ($adjacents * 2))		
			{
				for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
				$pagination.= "...";
				$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
				$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";		
			}
			//in middle; hide some front and some back
			elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
			{
				$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
				$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
				$pagination.= "...";
				for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
				$pagination.= "...";
				$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
				$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";		
			}
			//close to end; only hide early pages
			else
			{
				$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
				$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
				$pagination.= "...";
				for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page)
						$pagination.= "<span class=\"current\">$counter</span>";
					else
						$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";					
				}
			}
		}
		
		//next button
		if ($page < $counter - 1) 
			$pagination.= "<a href=\"$targetpage?page=$next\">next »</a>";
		else
			$pagination.= "<span class=\"disabled\">next »</span>";
		$pagination.= "</div>\n";		

	}
?>
		<? 
						/*	$sql = "Select user_id,Fname,Lname,Email,Phone,Fax,Password,date_format(regdate,'%D %M %y') from register";
	$catres = mysql_query($sql); 
	$laxman=0;*/
	 while($catrow=mysql_fetch_array($catres))
	 { 
	 
	         fwrite($fp,$catrow['user_id']);
			 fwrite($fp,",");
		     fwrite($fp,$catrow['email']);
			 fwrite($fp, "\n");
	 
	 
	 
	//$laxman++; 
						  ?>
                         <div id="stufftotoggle">
                          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">
                            <td width="73" height="30" align="center" class="dataTableContent"><?php echo $catrow['user_id']; ?></td>
                            <td class="dataTableContent" align="left"><?php echo $catrow['email']; ?></td>
                            <td class="dataTableContent" align="left" style="padding-left:15px;">
                   <?          
 if($_GET['userid']!=$catrow['user_id'])
{?>
           <a href="hookmeup.php?edit=edit&userid=<? echo $catrow['user_id']; ?>&page=<?php echo $_GET['page']; ?>">
                   <img src="images/icon_info.gif" border="0" />                   </a>
                   
           <? } else
		   {?>
            <a href="hookmeup.php?edit=edit&userid=<? echo $catrow['user_id']; ?>&page=<?php echo $_GET['page']; ?>">
                            
                   <img src="images/icon_arrow_right.gif" border="0" />                   </a>
           <?
		   }?> 
		   
		   
		   
		   
		    <? if($catrow['Status']==0){?>
    <a href="bulk.php?action=regstatus1&userid=<? echo $catrow['user_id'];?>&page=<?php echo $_GET['page']; ?>&status=1"><span class="index_text"><img src="images/publish_r.png" border="0" /></span></a> 
			<? } else {?>
            
     <a href="bulk.php?action=regstatus1&userid=<? echo $catrow['user_id']; ?>&page=<?php echo $_GET['page']; ?>&status=0"><span class="index_text"><img src="images/publish_g.png" border="0" /></span></a> 
            <? } ?> 
                  
                  <? }
				  
				  fclose($fp);
				  
				  
				  
				  ?>                          </td>
                          </tr>
                          <tr >
                            <td height="30" align="center" class="dataTableContent">&nbsp;</td>
                            <td class="dataTableContent" align="left">&nbsp;</td>
                            <td class="dataTableContent" align="left" style="padding-left:15px;">
                            
                            
<a href="downloadsacc.php?name=newsletter">
          <img src="images/downloadcsv.jpg" width="105" height="22" border="0" alt="Download CSV"  title="Download CSV"/>
</a>


</td>
                          </tr>
                          </div>
                         
                        </table></td>
                      </tr>
                      <tr>
                        <td width="22%" height="35">&nbsp;</td>
                        <td align="center"><?=$pagination?></td>
                        </tr>
                    </table></td>
                    <td width="28%" valign="top">
                    <? if($_GET['edit']=='edit')
				    {
					
						
						?> <form action="bulk.php?action=delete1" method="post" enctype="multipart/form-data" name="frm" id="frm" onsubmit="return validate(this);"> 
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F2F1EE">
                      
                        <tr>
                          <td height="17" align="center" bgcolor="#D7D6CC" class="dataTableHeadingContent"><table cellspacing="0" cellpadding="0">
                            <tr>
                              <td><strong>ID#<? echo $rowc['categoryname']; ?><? echo $rowc['Fname']; ?> <? echo $rowc['Lname']; ?></strong></td>
                            </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td height="10" align="center"><strong><span id="errorMessage"></span></strong></td>
                        </tr>
                        <tr>
                          <td height="25" align="center" valign="top">
                          
                      
						  
						  <input type="image" src="images/button_delete.gif" width="65" height="22" border="0" />
						                           </td>
                        </tr>
                        <tr>
                          <td height="25" align="center" valign="bottom" style="padding-left:5px;"><a href="delete.php"></a> &nbsp;<a href="email.php"></a>&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="17" align="center"><span style="padding-left:5px;">Are you sure you want to delete this user?&nbsp;&nbsp;</span></td>
                        </tr>
                        <tr>
                          <td><input type="hidden" name="page" value="<?=$_GET['page']?>"/>
						  
						  <input type="hidden" name="userid" value="<?=$_GET['userid']?>"/>
						  </td>
                        </tr>
                    </table>
					</form>
                  <? } ?></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><? require_once("footer.php"); ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
