
<?php \Laravel\Section::start('content'); ?>
	<div class="container">
		<div class="page-header">
			<h1><?php echo __('admin.newsletter'); ?></h1>
		</div>

		<?php if (Session::has('errors')): ?>
        <div class="alert alert-error">
			<button type="button" class="close" data-dismiss="alert">×</button>
			<?php echo  $errors->first('email') ; ?>
		</div>
		<?php endif; ?>

		<?php echo  BHelpers::notification() ; ?>
		<div style="margin-bottom: 15px;text-align:center">
			<?php echo  Form::open(URL::to_route('newsletter'), 'POST', array('class' => 'form-inline')) ; ?>
				<?php echo  Form::text('email', Input::old('email'), array('placeholder' => 'Email')) ; ?> <button type="submit" class="btn"><?php echo __('admin.ajouter'); ?></button>&nbsp;&nbsp;&nbsp;&nbsp; 
				<button type="button" onclick="window.location='<?php echo  URL::to_route('newsletter_export') ; ?>'" class="btn"><?php echo __('admin.export_csv'); ?></button>
			<?php echo  Form::close() ; ?>
		</div>
		<?php if($newsletter): ?>
		<table class="table table-striped table-hover datatable">
			<thead>
				<tr>
					<th>#</th>
					<th><?php echo __('admin.email'); ?></th>
					<th><?php echo __('admin.pays'); ?></th>
					<th><?php echo __('admin.date_ajout'); ?></th>
					<th>&nbsp;</th>
				</tr>
			</thead>
			<tbody>
				<?php foreach($newsletter as $n): ?>
				<tr>
					<td><?php echo  $n->id ; ?></td>
					<td><?php echo  $n->email ; ?></td>
					<td><?php echo  $n->country->fr ; ?></td>
					<td><?php echo  $n->created_at ; ?></td>
					<td style="padding: 4px 8px;text-align:right">
						<?php echo  Form::open(URL::to_route('delete_newsletter', $n->id), 'DELETE', array('id' => 'form_'.$n->id, 'style' => 'margin:0;')) ; ?>
						<a class="btn btn-small btn-danger" href="javascript:delete_entry(<?php echo $n->id ?>);"><i class="icon-remove icon-white"></i> <?php echo __('admin.supprimer'); ?></a>
						<?php echo  Form::close() ; ?>
					</td>
				</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
		<?php else: ?>
			<em><?php echo __('admin.aucune_adresse'); ?></em>
		<?php endif; ?>
	</div>
	<script type="text/javascript">
	function delete_entry(id)
	{
		if(confirm("<?php echo __('admin.etes_vous_sur'); ?>"))
			$('#form_'+id).submit();
		else
			return false;
	}
	</script>
<?php \Laravel\Section::stop(); ?>
<?php echo view('backend::template_default')->with(get_defined_vars())->render(); ?>