{include file="./index_top.tpl"}
<script language="JavaScript" type="text/javascript">
    // значения для системной подсказки
    var help_section = 'Settings';
    var help_sub_section = 'Mailer';
</script>
<div align=center>
    <br>
    <style>#mailing_title a { font-size:14px }</style>
    <div id="mailing_title">
        {if $smsc_on || $wazzup_on}<b>{/if}{$lang.Mailer} {$lang.mails}{if $smsc_on || $wazzup_on}</b>{/if}<span class='help_bt' h_id='Mailer'></span>
        {if $smsc_on}/ <a href="edit_smsing.php">{$lang.Mailer} {$lang.SMS}</a><span class='help_bt' h_id='SMS Mailer'></span>{/if}
        {if $wazzup_on}/ <a href="edit_msging.php">{$lang.Mailer} {$lang.messages}</a><span class='help_bt' h_id='Message Mailer'></span>{/if}
    </div>
    <br>
    {if $config.invalid_cron}
        <div class='error_mess' style="padding: 0px 0px 8px 0px;">{$lang.invalid_cron_no_sending}</div>
        <br>
    {/if}
    {if $archive}
        <div style="font-size:13px;">
            <a href="edit_mailing.php">{$lang.Active_mailer}</a><span class="help_bt" h_id="mailer_active"></span> /
            <b>{$lang.Ended_mailer}</b><span class="help_bt" h_id="mailer_ended"></span>
            {if $user.sub_admin_rights.smtp || $user.group_id == 1}/ <a href="edit_smtp.php">{$lang.Mailer_settings}</a><span class="help_bt" h_id="mailer_param"></span>{/if}
        </div>
        <br>
    {else}
        <div style="font-size:13px;">
            <b>{$lang.Active_mailer}</b><span class="help_bt" h_id="mailer_active"></span> /
            <a href="edit_mailing.php?archive">{$lang.Ended_mailer}</a><span class="help_bt" h_id="mailer_ended"></span>
            {if $user.sub_admin_rights.smtp || $user.group_id == 1}/ <a href="edit_smtp.php">{$lang.Mailer_settings}</a><span class="help_bt" h_id="mailer_param"></span>{/if}
        </div>
        <br>
    {/if}
    {if $archive && ($all_threads || $search_name || $search_email)}
        <form id="search_form">
            <div style="margin-bottom:15px">
                {$lang.Mailer}: <select class="form-control form-control-250" name="search_name" id="search_name" 
                                        onchange="if ($('#search_name').val() || $('#search_email').val()) 
                                                    document.getElementById('search_form').submit();
                                                  else 
                                                    location.href = 'edit_mailing.php?archive'">
                    <option value="">{ldelim}{$lang.All}{rdelim}</option>
                    {foreach from=$thread_names item=one_name}
                        <option value="{$one_name}" {if $one_name == $search_name}selected{/if}>{$one_name}</option>
                    {/foreach}
                </select> &nbsp;&nbsp;
                E-mail: <input class="form-control form-control-160" type="text" name="search_email" id="search_email" value="{$search_email}" 
                               placeholder="{$lang.Enter_search_text}">&nbsp;
                <input class="btn btn-default btn-sm" type="submit" value="{$lang.Search}" style="margin-top:-3px" 
                       onclick="if (!$('#search_name').val() && !$('#search_email').val()) { location.href = 'edit_mailing.php?archive'; return false; }">&nbsp;
                <input class="btn btn-default btn-sm" type="button" value="{$lang.Reset}" style="margin-top:-3px" 
                       onclick="{if $search_name || $search_email}location.href = 'edit_mailing.php?archive'{else}$('#search_email').val(''){/if}">
                <script>$('#search_name').chosen()</script>
            </div>
        </form>
    {/if}
    {if !$all_threads && !$prep_threads}
        {if !$archive}
            {$lang.no_cron_tasks}
        {else}
            {$lang.Nothing_found}
        {/if}
    {else}
        <table cellpadding=5 cellspacing=0>
            <tr>
                {foreach from=$headers item=one_header}
                    <td style="border-bottom:1px gray solid;"><b>{$one_header}</b></td>
                {/foreach}
            </tr>
            {foreach from=$prep_threads item=one_thread}
                <tr>
                    {foreach from=$one_thread item=one_field key=name}
                        <td style="border-bottom:1px gray dotted;color:gray"
                            {if $name=="report" or $name=="end_time" or $name=="scheduled_time"}align=center{/if}>{$one_field}
                        </td>
                    {/foreach}
                </tr>
            {/foreach}
            {foreach from=$all_threads item=one_thread}
                <tr>
                    {foreach from=$one_thread item=one_field key=name}
                        <td style="border-bottom:1px gray dotted"
                            {if $name=="report" or $name=="end_time" or $name=="scheduled_time"}align=center{/if}>{$one_field}
                        </td>
                    {/foreach}
                </tr>
            {/foreach}
        </table>
        <br>
        <div align=center class="pages">
            {foreach from=$all_pages item=one_page}
                {if $one_page eq $page}
                    <span>{$one_page}</span>
                {elseif $one_page eq '...'}
                    {$one_page}
                {else}
                    <a href="edit_mailing.php?{if $search}search={$search}&{elseif $archive}archive&{/if}page={$one_page}">{$one_page}</a>
                {/if}
            {/foreach}
        </div>
        <br>
    {/if}
</div>