{include file="./index_top.tpl"}
<div align=center>
    {if $start_mailing}
    <br><span style="font-size:14px;">{$lang.Mailer_started}.</span><br>
    {if $user.group_id == 1 && $mode != 'msg'}
        <br>
        <a href="{if $mode=='send'}edit_mailing{elseif $mode=='sms'}edit_smsing{/if}.php">{$lang.Active_mailer}</a>
        <br>
    {/if}
    <br><a href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}{if $archive}&archive{/if}{$back_url_prm}">{$lang.Back}</a></br></br>
    {else}
    {if $sel_on and $all_forms}
        <br>
        {if $mode=="send"}{$lang.select_mail_template}{elseif $mode=="sms"}{$lang.select_sms_template}{elseif $mode=="msg"}{$lang.select_msg_template}{else}{$lang.select_print_template}{/if}:
        <br>
    {else}
        <br>
        {if $mode=="send"}{$lang.Mail_templates}{elseif $mode=="sms"}{$lang.SMS_templates}{elseif $mode=="msg"}{$lang.Msg_templates}{else}{$lang.Print_templates}{/if}
        <br>
    {/if}
    <p style="font-size:14px; margin-top:8px;">
        {if $archive}<a style="font-size:14px;" href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}{$back_url_prm}">{/if}
            {$lang.active}
        {if $archive}</a>{/if}
        /
        {if !$archive}
            {if $has_archive}
                <a style="font-size:14px;" href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&archive{$back_url_prm}">
            {else}
                <span style="color:gray" title="{$lang.Empty_archive}">
            {/if}
        {/if}
            {$lang.archive}
        {if !$archive}{if $has_archive}</a>{else}</span>{/if}{/if}
    </p>
    <table border=0 cellpadding=3>
        {if $free_form}
            <tr>
                <td colspan="{if $add_form_acc}3{else}2{/if}"></td>
                <td>
                    <a href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&form={$free_form.id}&edit{$back_url_prm}"><img
                                alt="{$lang.edit}" title="{$lang.Edit_template}" src="images/b_edit.png" border=0></a>
                </td>
                <td></td>
                <td>{$free_form.name_form|escape:'html'}</td>
            </tr>
        {/if}
        {foreach from=$all_forms item=one_form}
            {if $one_form.read}
                <tr>
                    <td>
                        {if $one_form.edit}
                            {if !$archive}
                                <a class='href_post'
                                   href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&form={$one_form.id}&to_arc{$back_url_prm}"><img
                                            alt="{$lang.into_archive}" title="{$lang.send_in_archive}"
                                            src="images/b_archive.png" border=0></a>
                            {else}
                                <a class='href_post'
                                   href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&archive&form={$one_form.id}&from_arc{$back_url_prm}"><img
                                            alt="{$lang.restore}" title="{$lang.restore_from_archive}"
                                            src="images/b_restore.png" border=0></a>
                            {/if}
                        {/if}
                    </td>
                    <td>{if $one_form.del}<a class='href_post'
                                             href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}{if $archive}&archive{/if}&form={$one_form.id}&delete{$back_url_prm}"
                                             onClick='return href_post=jconfirm("{$lang.alert_delete_template}", this);'>
                            <img alt="{$lang.delete}" title="{$lang.Delete_template}" src="images/b_drop.png" border=0>
                            </a>{/if}</td>
                    {if $add_form_acc}
                        <td><a class='href_post'
                               href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}{if $archive}&archive{/if}&form={$one_form.id}&amp;copy{$back_url_prm}"
                               onClick="if (copy_name=prompt('{$lang.Copy_as}','{$one_form.name_form} {$lang['(copy)']}')) {ldelim}this.href=this.href+'&amp;copy='+copy_name; href_post=true;{rdelim} else href_post=false;"><img
                                    alt="{$lang.copy}" title="{$lang.Copy_template}" src="images/b_copy.png"
                                    border=0></a></td>{/if}
                    <td>{if $one_form.edit}<a
                            href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&form={$one_form.id}&edit{$back_url_prm}">
                            <img alt="{$lang.edit}" title="{$lang.Edit_template}" src="images/b_edit.png" border=0>
                            </a>{/if}</td>
                    {if ($mode=="send" or $mode=="sms" or $mode=="msg") and $sel_on}
                        <td>
                        <a href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&form={$one_form.id}&view"
                           onclick="window.open(this.href);return false;"><img alt="{$lang.view}" title="{$lang.View_mode}" src="images/b_view.png" border=0></a>
                        </td>{/if}
                    <td>{if $sel_on}<a
                                href="forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&form={$one_form.id}"
                                {if $mode=="send" and (!$smtp_ready || $tariff_limits.mailing_off)}onclick="jalert('{$lang.alert_no_smtp_servers}'); return false;"
                                {elseif $mode=="send" and $one_form.warning}onclick="jalert('{$one_form.warning}'); return false;"
                                {elseif $mode=="print" and $one_form.type_form<3}onclick="window.open(this.href);return false;"{/if}>{/if}{$one_form.name_form|escape:'html'}{if $sel_on}</a>{/if}
                    </td>
                </tr>
            {/if}
        {/foreach}
    </table>
    <br>
    {if $add_form_acc and !$archive}
    <p><input class="btn btn-default btn-sm" type="button" value="{$lang.Add_template}"
              onclick="location.href='forms.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}&mode={$mode}&form=-1&edit{$back_url_prm}'"/>
    <p>
        {/if}
        <br><a href="{if $back_url}{$back_url}{else}fields.php?table={$table_id}{if $filter_id}&filter={$filter_id}{/if}{/if}">{if $back_url}{$lang.Return}{else}{$lang.return_to_table}{/if}</a><br><br>
        {/if}
</div>
<input type=hidden name=csrf value='{$csrf}'>
