{include file="./index_top.tpl"}
<script language="JavaScript" type="text/javascript">
    // значения для системной подсказки
    var help_section = 'Settings';
    var help_sub_section = 'Mailer';

    $(function () {
        $('.datepicker').datepicker({
            showOn: "button",
            dateFormat: lang.date_js_format,
            showAlways: true,
            buttonImage: "images/calbtn.png",
            buttonImageOnly: true,
            buttonText: "Calendar",
            showAnim: (('\v' == 'v') ? "" : "show"),  // в ie не включаем анимацию, тормозит
        }).attr('placeholder', lang.date_placeholder);
    });
</script>
<div align=center>
    <br>
    <style>#mailing_title a { font-size:14px }</style>
    <div id="mailing_title">
        <a href="edit_mailing.php">{$lang.Mailer} {$lang.mails}</a><span class='help_bt' h_id='Mailer'></span>
        / <b>{$lang.Mailer} {$lang.SMS}</b><span class='help_bt' h_id='SMS Mailer'></span>
        {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_sms_send}</div>
        <br>
    {/if}
    {if $archive}
        <div style="font-size:13px;">
            <a href="edit_smsing.php">{$lang.Active_mailer}</a><span class="help_bt" h_id="mailer_active"></span> /
            <a href="edit_smsing.php?archive"><b>{$lang.Ended_mailer}</b></a><span class="help_bt" h_id="mailer_ended"></span> /
            <a href="edit_modules.php?module=sms&back_url={$base64_current_url}">{$lang.Mailer_settings}</a><span class="help_bt" h_id="SMS_module"></span>
        </div>
        <br>
    {else}
        <div style="font-size:13px;">
            <a href="edit_smsing.php"><b>{$lang.Active_mailer}</b></a><span class="help_bt" h_id="mailer_active"></span> /
            <a href="edit_smsing.php?archive">{$lang.Ended_mailer}</a><span class="help_bt" h_id="mailer_ended"></span> /
            <a href="edit_modules.php?module=sms&back_url={$base64_current_url}">{$lang.Mailer_settings}</a><span class="help_bt" h_id="SMS_module"></span>
        </div>
        <br>
    {/if}
    <div style="font-size:14px;display:flex;align-items: center;justify-content: center;">
        {$name}{if $form.table_id}<a class="settings" style="margin-left:8px;" href="forms.php?admin&table={$form.table_id}&mode=send&form={$form.id}&edit" title="{$lang.Edit_template}" target="_blanc"></a>{/if}
    </div>
    <br>
    {if $archive}
        {if $sended}
            <div style="font-size:13px;"><b>{$lang.Sended}</b> / <a
                        href="edit_smsing.php?thread={$thread_id}&archive&delivered">{$lang.Delivered}</a> / <a
                        href="edit_smsing.php?thread={$thread_id}&archive&failed">{$lang.Failed}</a></div>
            <br>
        {elseif $delivered}
            <div style="font-size:13px;"><a href="edit_smsing.php?thread={$thread_id}&archive&sended">{$lang.Sended}</a>
                / <b>{$lang.Delivered}</b> / <a
                        href="edit_smsing.php?thread={$thread_id}&archive&failed">{$lang.Failed}</a></div>
            <br>
        {elseif $failed}
            <div style="font-size:13px;"><a href="edit_smsing.php?thread={$thread_id}&archive&sended">{$lang.Sended}</a>
                / <a href="edit_smsing.php?thread={$thread_id}&archive&delivered">{$lang.Delivered}</a> /
                <b>{$lang.Failed}</b></div>
            <br>
        {/if}
    {else}
        {if $sended}
            <div style="font-size:13px;"><a href="edit_smsing.php?thread={$thread_id}">{$lang.In_queue}</a> /
                <b>{$lang.Sended}</b> / <a href="edit_smsing.php?thread={$thread_id}&delivered">{$lang.Delivered}</a> /
                <a href="edit_smsing.php?thread={$thread_id}&failed">{$lang.Failed}</a></div>
            <br>
        {elseif $delivered}
            <div style="font-size:13px;"><a href="edit_smsing.php?thread={$thread_id}">{$lang.In_queue}</a> / <a
                        href="edit_smsing.php?thread={$thread_id}&sended">{$lang.Sended}</a> / <b>{$lang.Delivered}</b>
                / <a href="edit_smsing.php?thread={$thread_id}&failed">{$lang.Failed}</a></div>
            <br>
        {elseif $failed}
            <div style="font-size:13px;"><a href="edit_smsing.php?thread={$thread_id}">{$lang.In_queue}</a> / <a
                        href="edit_smsing.php?thread={$thread_id}&sended">{$lang.Sended}</a> / <a
                        href="edit_smsing.php?thread={$thread_id}&delivered">{$lang.Delivered}</a> /
                <b>{$lang.Failed}</b></div>
            <br>
        {else}
            <div style="font-size:13px;"><b>{$lang.In_queue}</b> / <a
                        href="edit_smsing.php?thread={$thread_id}&sended">{$lang.Sended}</a> / <a
                        href="edit_smsing.php?thread={$thread_id}&delivered">{$lang.Delivered}</a> / <a
                        href="edit_smsing.php?thread={$thread_id}&failed">{$lang.Failed}</a></div>
            <br>
        {/if}
    {/if}
    <form method=post>
        <div class="search_bar" style="line-height:35px; border-bottom:1px solid #e3e3e3">
            <span class="search_cell">
                {$lang.Period}
                {$lang.since_from} <input type=text name="st_date" value="{$st_date}" maxlength=10 class="datepicker form-control">
                {$lang.since_to} <input type=text name="end_date" value="{$end_date}" maxlength=10 class="datepicker form-control">
                <input type="hidden" name="csrf" value="{$csrf}"/>
                <input class="btn btn-default btn-sm" type=submit value="{$lang.Apply}">
            </span>
        </div>
    </form>
    <br>
    <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=$all_sms item=one_sms}
            <tr>
                {foreach from=$one_sms item=one_field key=name}
                    <td style="border-bottom:1px gray dotted" {if $name=="report"}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_smsing.php?thread={$thread_id}{if $archive}&archive{/if}{if $sended}&sended{elseif $delivered}&delivered{elseif $failed}&failed{/if}&page={$one_page}">{$one_page}</a>
            {/if}
        {/foreach}
    </div>
    <br>
</div>