<link rel="stylesheet" type="text/css" href="{$config.site_root}/modules/mail/css/style.css?{$revision}">
<script type="text/javascript" src="modules/mail/lang/{$config.lang}.js?{$revision}"></script>
<div style="font-size:16px;margin:0 auto 10px" align="center">
    <b>{$lang['modules']['mail']['setting_top']} </b><span class="help_bt"
                                                    h_id="setting_top_mail"></span>
</div>
<div align="center" class="f13">
    <a href="?module=mail">{$lang['modules']['mail']['inset1']}</a> /
    <a href="?module=mail&path=table">{$lang['modules']['mail']['inset2']}</a> /
    {$lang['modules']['mail']['inset3']} /
    <a href="?module=mail&path=server">{$lang['modules']['mail']['inset4']}</a> /
    <a href="?module=mail&path=black">{$lang['modules']['mail']['inset5']}</a> /
    <a href="?module=mail&path=sets"> {$lang['modules']['mail']['inset6']}</a>
</div>
<br/>
<br/>
<div align="center">
    {$lang['modules']['mail']['inset3top']}
    <br/>
    <br/>
    {if $mail_box}
        <form method="post" action="" id="email_form">
            <table class="em_table">
                <tr>
                    <th> {$lang['modules']['mail']['inset3status']} </th>
                    <th> {$lang['modules']['mail']['inset3accaunt']} </th>
                    <th> {$lang['modules']['mail']['inset3user']} </th>
                    <th> {$lang['modules']['mail']['inset3server']} </th>
                    <td></td><td></td>
                    <td><input type="checkbox" onclick="$('.check_box').prop('checked', this.checked); $('#delete_checked').toggle(this.checked)"></td>
               </tr>
                {foreach from = $mail_box item = subtable  name=row}
                    <tr>
                        <td style="cursor: pointer" onclick="checkmailimap({$subtable.id})">{$subtable.check_status}</td>
                        <td>{$subtable.email}</td>
                        <td style='min-width:150px'>{$subtable.us}</td>
                        <td style='width:150px'>{$subtable.server_mail}</td>
                        <td>
                            <a class='no_border'>
                                <img style='cursor:pointer'
                                     onclick='location.href="{$config.site_url}/edit_modules.php?module=mail&path=edit_mail&id={$subtable.id}"'
                                     src='{$config.site_root}/images/b_edit.png'>
                            </a>
                        </td>
                        <td>
                            <a class='no_border'
                               onclick="return href_post=jconfirm ('{$lang.modules.mail.insetdelete}<p> <input type=checkbox onclick=set_cokkiess(this.checked)> {$lang.modules.mail.del_lines}</p>', this);"
                               href='{$config.site_url}/edit_modules.php?module=mail&path=del&del=mail&id={$subtable.id}'>
                                <img src='{$config.site_root}/images/b_drop.png'>
                            </a>
                        </td>
                        <td>
                            <input class="check_box" type="checkbox" name="checked[]" value="{$subtable.id}" onclick="$('#delete_checked').show()">
                        </td>
                    </tr>
                {/foreach}
            </table>
            <br/>
            <input type="hidden" name="csrf" value="{$csrf}">
            <button class="btn btn-default btn-sm" type="button" id="delete_checked" style="display:none"
                    onclick="jconfirm('{$lang.modules.mail.insetdelete}<p> <input type=checkbox onclick=set_cokkiess(this.checked)> {$lang.modules.mail.del_lines}</p>', 
                             function() { document.getElementById('email_form').submit(); })"> {$lang.modules.mail.delete_selected_boxes} </button>
        </form>
        <br/>
    {/if}
    {if $mail_box}
        <a href="{$config.site_url}/edit_modules.php?module=mail&path=mail&action=check">{$lang['modules']['mail']['Check_connection']}</a>
        <br/>
        <br/>
    {/if}

    <button class="btn btn-default btn-sm"
            onclick='table_select.style.display="block"'> {$lang['modules']['mail']['insetadd']} </button>
    <br/>
    <br/>
    <div id="table_select" class="d_n">
        {if $warn}
            <form method="post" action="">
                <table cellpadding="2" class="for_table">
                    <tbody>
                    <tr>
                        <td align="right">
                            {$lang['modules']['mail']['inset3email']} <span class="help_bt" h_id="Email_email"></span>:
                        </td>
                        <td>
                            <input class="form-control form-control-160" type="text" name="email" id="em"
                                   onblur="checkmail('{$email}')" required title="">
                            <span class="c_r" id="alt"></span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            {$lang['modules']['mail']['inset3password']} <span class="help_bt"
                                                                               h_id="Email_password"></span>:
                        </td>
                        <td>
                            <input class="form-control form-control-160" type="password" name="password" title="">
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td colspan="3">
                            <a id="open_add_set" class="undl"
                               onclick="op('add')"> {$lang['modules']['mail']['inset3else']} </a>
                            <a id="config_access_rules" class="undl"
                               onclick="op('users')"> {$lang['modules']['mail']['inset3user']} </a>
                        </td>
                    </tr>
                    </tbody>
                    <tbody id="users" class="d_n">
                    <tr>
                        <td align="right"> {$lang['modules']['mail']['inset3user']} <span class="help_bt"
                                                                                          h_id="Email_user"></span>:
                        </td>
                        <td></td>
                    </tr>
                    {$users}
                    {if $users3}
                    <tr>
                        <td></td>
                        <td><a id="but_user" class="undl"
                               onclick="op_user()">{$lang['modules']['mail']['no_activ_user']}</a></td>
                    </tr>
                    <tbody id="no_activ" class="d_n">
                    {$users3}
                    </tbody>
                    {/if}
                    </tbody>
                    <tbody id="dop" class="d_n">
                    <tr>
                        <td align="right">
                            {$lang['modules']['mail']['provaider']} <span class="help_bt"
                                                                          h_id="Email_provaider"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-75" name="provaider" title="">
                                <option value="0">{$lang.modules.mail.auto}</option>
                                {$provaider}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            {$lang['modules']['mail']['inset3investment']} <span class="help_bt"
                                                                                 h_id="Email_investment"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-75" name="ads" title="">
                                <option value="0">{$lang.modules.mail.no}</option>
                                <option value="1" selected>{$lang.modules.mail.yes}</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            {$lang['modules']['mail']['inset3sent']} <span class="help_bt" h_id="Email_sent"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-75" name="sends" title="">
                                <option value="0">{$lang.modules.mail.no}</option>
                                <option value="1" selected>{$lang.modules.mail.yes}</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            {$lang['modules']['mail']['inset3max']} <span class="help_bt" h_id="Email_max"></span>:
                        </td>
                        <td>
                            <input class="form-control form-control-160" type="text"
                                   name="max_mail" {if $trial} disabled  value="3" {/if} title="">
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            {$lang['modules']['mail']['inset3sign']} <span class="help_bt" h_id="Email_sign"></span>:
                        </td>
                        <td>
                            <textarea class="form-control" name="sign" id="editor1" rows="10" cols="80" title="">
                            </textarea>
                            <script type="text/javascript" src="{$config.site_root}/themes/clientbase/libs/ckeditor/ckeditor.js?{$revision}"></script>
                            <script>
                                CKEDITOR.replace('editor1');
                            </script>
                        </td>
                    </tr>
                    <tr>
                        <td align="right"> {$lang['modules']['mail']['inset3new']} <span class="help_bt"
                                                                                         h_id="Email_new_table"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-160" name="tabmail"
                                    onchange="add_new(this.options[this.selectedIndex].value)" title="">
                                <option value="">{$lang['modules']['mail']['insetno']}</option>
                                {foreach from = $tabmail item = subtable  name=row}
                                    <option value='{$subtable.id}'>{$subtable.name_table}</option>
                                {/foreach}
                            </select>
                        </td>
                    </tr>
                    </tbody>
                    <tbody id="tabmail" class="d_n">
                    <tr>
                        <td align="right">{$lang['modules']['mail']['new_records_option']} <span class="help_bt"
                                                                                        h_id="Email_new_table2"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-160" name="new_records_always">
                                <option value='1'>{$lang['modules']['mail']['new_records_option1']}</option>
                                <option value='0'>{$lang['modules']['mail']['new_records_option0']}</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right"> {$lang['modules']['mail']['inset3fem']} <span class="help_bt"
                                                                                         h_id="Email_new_email"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-160" name="fmail" id="tabmail1" title="">
                                {$fmail}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right"> {$lang['modules']['mail']['inset3fsub']} <span class="help_bt"
                                                                                          h_id="Email_new_subject"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-160" name="smail" id="tabmail2" title="">
                                <option value="0">{$lang['modules']['mail']['insetno']}</option>
                                {$fmail}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right"> {$lang['modules']['mail']['inset3fbody']} <span class="help_bt"
                                                                                           h_id="Email_new_body"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-300" name="bmail" id="tabmail3" title="">
                                <option value="0">{$lang['modules']['mail']['insetno']}</option>
                                {$fmail}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right"> {$lang['modules']['mail']['inset3finv']} <span class="help_bt"
                                                                                           h_id="Email_new_investment"></span>:
                        </td>
                        <td>
                            <select class="form-control form-control-300" name="imail" id="tabmail4" title="">
                                <option value="0">{$lang['modules']['mail']['insetno']}</option>
                                {$fmail}
                            </select>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <input type="hidden" name="users" id="uss" value="{$usermain}">
                <div class="clear"></div>
                <br/>
                <input type=hidden name="csrf" value="{$csrf}">
                <input type="hidden" name="action" value="save">
                <input class="btn btn-default btn-sm" id="butt" type=submit
                       value="{$lang['modules']['mail']['insetsave']}">
                <button class="btn btn-default btn-sm" type="button"
                        onclick="window.location='{$config.site_url}/edit_modules.php?module=mail&path=mail';">{$lang['modules']['mail']['insetcancel']}</button>
            </form>
        {else}
            <div class="c_r" align="center">{$lang['modules']['mail']['activate']}</div>
        {/if}
    </div>
    <br/>
    <br/>
</div>
<script type="text/javascript" src="{$config.site_root}/modules/mail/js/script.js?{$revision}"></script>
<script>
    $(document).ready(() => {
        init_chosen();
    });
</script>