<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2008 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts EasyCart                      |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
 <script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmUsers.submit();
}
</script>

 <?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>			
<div align="center" class="subheading">
 <div align="left">NEWSLETTER CONTENTS</div>
</div>
<br />
<div>
<!--search area start -->					
					<form action="" method="get" name="frmUsers">
    				<div>
					<div style=float:left>  	
  		 			 <select name="cmbSearchType" class="box2_admin">
					<option value="title"  <?php if($cmbSearchType == "title" || $cmbSearchType == ""){ echo("selected"); } ?>>Title</option>
					<option value="content"  <?php if($cmbSearchType == "content"){ echo("selected"); } ?>>Content</option>
					</select> &nbsp;
					<input type="text" name="txtSearch" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>" class="box2_admin" >
					 </div>
				   <div>
					<a style="cursor:pointer" onClick="javascript:clickSearch();"><?php echo $html->image('/img/search_bttn.gif');?></a>
					 </div>		
					 <br />							
				   </form>	
				         <br />
                      <label>
					  <strong  class="btn_style-org"><?php echo $html->link('Add Newsletter','/newsletters/add')?> >></strong>
					  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					  <strong class="btn_style-org" style="width:200px; "><?php echo $html->link('Newsletter Subscribers','/newsletterusers/')?> >></strong>
					  </label>
				     <br />	 <br />							
<!--search area end -->					
</div>
<div align="left" id="item_details_admin">
				<!--items display area start -->
				 <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table">
				  <tr>
					<td align="left" valign="top">
					<table width="100%"  border="0" cellspacing="1" cellpadding="6">
					  <tr align="left" valign="middle" id="list_admin_top" >
						<td width="5%" class="brd-btm brd-ryt">#</td>
						<td width="20%"  class="brd-btm brd-ryt"><?php echo $paginator->sort('Title', 'title'); ?></td>
						<td width="40%" class="brd-btm brd-ryt"><?php echo $paginator->sort('Content', 'content'); ?></td>
						<td width="10%" class="brd-btm brd-ryt"><?php echo $paginator->sort('Date', 'news_date'); ?></td>
						<td width="15%" class="brd-btm">Options</td>
					  </tr>
					 <?php
						if(!empty($passedarg) && !isset($passedarg["page"]))								
									$cnt=1;
									else if(!empty($passedarg) && $passedarg["page"]==1)
									$cnt=1;
									else
									$cnt=($passedarg["page"]*$passedarg["limit"]-1);
					   if(!empty($newsletter))
					   {
					    foreach ($newsletter as $letters){ ?> 
							  <tr align="left" valign="middle" id="list_admin">
								<td valign="top" class="brd-ryt"><?php echo $cnt++;?></td>
								<td valign="top" class="brd-ryt">
								<?php 
								//$title=Sanitize::html($letters['Newsletter']['title']); 
								echo $html->link(htmlspecialchars_decode($letters['Newsletter']['title']), "/sentnewsletters/show/".$letters['Newsletter']['id']); ?>
								</td>
								<td valign="top" class="brd-ryt">
								<?php echo htmlspecialchars_decode($letters["Newsletter"]["content"]); ?>
								</td>
								<td valign="top" class="brd-ryt">								
								<?php 
								if(isset($letters["Newsletter"]["news_date"])) { 
								$date=explode(" ",$letters["Newsletter"]["news_date"]);
								$dte=explode("-",$date[0]);
								echo $dte[1]."-".$dte[2]."-".$dte[0];}
								?>
								</td>						
								<td valign="top">
								<?php echo $html->link('Send to Retail Users', 
				"/newsletters/sendRetail/".$letters['Newsletter']['id'],null,'Are you sure you want to send the Newsletter to all Retail users.'); ?> 
				<br /><br />
				<?php echo $html->link('Send to Wholesale Users', 
				"/newsletters/sendWholesale/".$letters['Newsletter']['id'],null,'Are you sure you want to send the Newsletter to all Wholesale users.'); ?> 
				<br /><br />
				<?php echo $html->link('Send to Wholesale & Retail Users', 
				"/newsletters/sendNewsletter/".$letters['Newsletter']['id'],null,'Are you sure you want to send the Newsletter to all Wholesale and Retail users.'); ?> 
				<br /><br />
								 <?php
                                                                 if($cnfg['streamsendEnable'] == 'Y'){
                                                                echo $html->link('Send by Streamsend',
				"/newsletters/streamsend/".$letters['Newsletter']['id'],null,'Are you sure you want to send the Newsletter by streamsend.');
                                                                 }
                                                                 ?>
								<br /><br />
								<?php echo $html->link('Edit', "/newsletters/edit/".$letters['Newsletter']['id']); ?>
								<br /><br />
								 <?php echo $html->link('Delete', 
				"/newsletters/delete/".$letters['Newsletter']['id'],null,'Are you sure you want to delete this Newsletter.'); ?>

                                                                

                                                                </td>
							  </tr>  
					   <?php  }  ?>					  
					  </table>					 
						  <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
						    <tr>
						       <td align="center"><?php echo $this->renderElement('pagination'); // Render the pagination element ?></td>
						    </tr>
					      </table>
						  <?php }  else { ?>					     
							<table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
						     <tr id="list_admin">
						       <td align="center"><strong>No Contents found!</strong></td>
						     </tr>
					        </table>			  
						  <?php } ?>
				    </td>
				  </tr>
				</table>
 </div>
				 <div align="left" class="float_clear1"></div>
				