{capture name=tabs}
{if in_array('currency', $manager->permissions)}<li><a href="index.php?module=CurrencyAdmin">Валюты</a></li>{/if}
	{if in_array('delivery', $manager->permissions)}<li><a href="index.php?module=DeliveriesAdmin">Доставка</a></li>{/if}
	{if in_array('payment', $manager->permissions)}<li><a href="index.php?module=PaymentMethodsAdmin">Оплата</a></li>{/if}
	{if in_array('managers', $manager->permissions)}<li><a href="index.php?module=ManagersAdmin">Менеджеры</a></li>{/if}
	<li class="active"><a href="index.php?module=MailingMethodsAdmin">Рассылка</a></li>
{/capture}

{* Title *}
{$meta_title='Управление Рассылкой' scope=parent}

{* Подключаем Tiny MCE *}
{include file='tinymce_init.tpl'}

{* Заголовок *}
<div id="header">
	<h1><a{if !$smarty.get.show} class="dash_link"{/if} href="index.php?module=MailingMethodsAdmin">Рассылка</a></h1><h1>|</h1><h1><a{if $smarty.get.show} class="dash_link"{/if} href="index.php?module=MailingMethodsAdmin&show=subscribers">Список подписчиков</a></h1>
</div>
{literal}
<style>.interactive{margin:5px 20px;position:absolute;display:none;}</style>
<script type="text/javascript">
$(document).ready(function () {
	$('form#mailpost_form').submit(function(){
		mail_letter = tinyMCE.activeEditor.getContent();
		mail_header = $("#mailpost_form #mail_header").val();
		if(mail_letter != '' && mail_header != ''){
			$('#mail_submit').prop("disabled", true);
			$('.interactive').css('display', 'none');
			$('.interactive.loading').css('display', 'inline');
			$.ajax({
				type: 'POST',
				url: 'index.php?module=MailingMethodsAdmin',
				data: 'session_id='+$("#mailpost_form #session_id").val()+'&header='+mail_header+'&letter='+mail_letter,
				success: function(data){
					$('.interactive.loading').css('display', 'none');
					$('.interactive.complete').css('display', 'inline');
					$('.interactive.complete').css('display', 'inline');
					$('#mail_submit').val('Рассылка завершена');
				}
			});
		}
		return false;
	});
});
</script>
{/literal}
<div id="main_div">
	{if $smarty.get.show}
	<form id="list_form" method="post" action="index.php?module=MailingMethodsAdmin&show=subscribers">
	<input type="hidden" name="session_id" value="{$smarty.session.id}">
		<div id="list">
			{$a=1}{foreach $mailing_email item=email key=id}{$a=$a+1}
			<div class="row{if $a%2===0} even{/if}">
				<div class="checkbox cell">
					<input type="checkbox" name="remove[]" value="{$id}" />
				</div>
				<div class="name cell">{$email}</div>
				<div class="icons cell">
					<a class="delete" title="Удалить" href="index.php?module=MailingMethodsAdmin&show=subscribers&remove={$id}"></a>
				</div>
				<div class="clear"></div>
			</div>
			{/foreach}
		</div>

		<div id="action">
		<label onclick="$('#list input[type=checkbox]').attr('checked', true);" class="dash_link">Выбрать все</label>
		<span id="select">
		<select name="action">
			<option value="delete">Удалить</option>
		</select>
		</span>

		<input id="apply_action" class="button_green" type="submit" value="Применить">

		</div>
	</form>
	{else}
		<form id="mailpost_form" method="post" action="index.php?module=MailingMethodsAdmin">
			<input type="hidden" id="session_id" name="session_id" value="{$smarty.session.id}">
			<p style="margin-bottom:10px"><label><b>Тема письма:&nbsp&nbsp</b></label><input id="mail_header" type="text" name="header" style="width:50%" /></p>
			<p><textarea id="mail_letter" name="letter" class="editor_small"></textarea></p>
			<p style="text-align:center;margin-top:20px;"><input class="button_green" id="mail_submit" type="submit" value="Разослать" style="margin-right: -12px;" /><img title="Выполняется рассылка" class="interactive loading" src="http://belfast.by/images/ajx_loading.gif"><img title="Рассылка завершена" class="interactive complete" src="design/images/accept.png"></p>
		</form>
	{/if}
</div>