<link rel="stylesheet" type="text/css" href="{$config.site_root}/modules/mail/css/style.css?{$revision}">
<script language="JavaScript" type="text/javascript">
    document.addEventListener('invalid', (function () {
        return function (e) {
            e.preventDefault();
            //document.getElementById("name").focus();
        };
    })(), true);
    function InvalidMsg(submitForm) {
        var mail_emai = document.getElementById('mail_emai').value;
        var password_edit_email = document.getElementById('password_edit_email').value;
        var provaider_edit_email = document.getElementById('provaider_edit_email').value;
        if (mail_emai == "") {
            jalert('{$lang.not_filed_field}  "E-mail {$lang.address}"');
            return false;
        } else if (password_edit_email == "") {
            jalert('{$lang.not_filed_field}  "{$lang.password}"');
            return false;
        } else if (provaider_edit_email == "") {
            jalert('{$lang.not_filed_field}  "{$lang.provaider}"');
            return false;
        } else { }
        $(submitForm).submit();
    }
</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 class="f13" align="center">
    <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']['inset3']}
    <div id="table_select">
        <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" required="required" id="mail_emai" name="email" value="{$mail['email']}"
                               required title="">
                    </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" required="required" id="password_edit_email" type="password" name="password"
                               value="{$mail['password']}" title="">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="3">
                        <a id="open_add_set" class="und mr20"
                           onclick="op('add')">{$lang['modules']['mail']['inset3else']}</a>
                        <a id="config_access_rules" class="und"
                           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>
                <tr>
                    <td align='right'>
                        <input id='usall' type='checkbox'
                               onclick='checkall("{$all_users}")' {$all_users_check}
                               title="">
                    </td>
                    <td>
                        {$lang['modules']['mail']['all']}
                    </td>
                </tr>
                {foreach from = $users item = subtable  name=row}
                    <tr>
                        <td align='right'>
                            <input id='us{$subtable.id}' class="check_us" type='checkbox'
                                   onclick='checks({$subtable.id})' {$subtable.check}
                                   title="">
                        </td>
                        <td>
                            {$subtable.fio}
                        </td>
                    </tr>
                {/foreach}
                {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">
                {foreach from = $users3 item = subtable  name=row}
                    <tr>
                        <td align='right'>
                            <input id='us{$subtable.id}' class="check_us" type='checkbox'
                                   onclick='checks({$subtable.id})' {$subtable.check}
                                   title="">
                        </td>
                        <td>
                            {$subtable.fio}
                        </td>
                    </tr>
                {/foreach}
                </tbody>
                {/if}
                </tbody>
                <tbody id="dop" class="d_n">
                <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-160" name="ads" title="">
                            {if $mail['ads'] == 0 }
                                <option value="0">Нет</option>
                                <option value="1">Да</option>
                            {else}
                                <option value="1">Да</option>
                                <option value="0">Нет</option>
                            {/if}
                        </select>
                    </td>
                </tr>

                <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-160" required="required" id="provaider_edit_email" name="provaider" title="">
                            {$provaider}
                        </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-160" name="sends" title="">
                            {if $mail['sends'] == 0 }
                                <option value="0">Нет</option>
                                <option value="1">Да</option>
                            {else}
                                <option value="1">Да</option>
                                <option value="0">Нет</option>
                            {/if}
                        </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"
                               {else}value="{if $mail['max_mail']}{$mail['max_mail']}{/if}" {/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="5" cols="10" title="">
                            {$mail['sign']}
                            </textarea>
                        <script type="text/javascript" src="{$config.site_root}/themes/clientbase/libs/ckeditor/ckeditor.js"></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_new2(this.options[this.selectedIndex].value)" title="">
                            {foreach from = $tabmail1 item = subtable  name=row}
                                <option value='{$subtable.id}'>{$subtable.name_table}</option>
                            {/foreach}
                            {foreach from = $tabmail item = subtable  name=row}
                                <option value='{$subtable.id}'>{$subtable.name_table}</option>
                            {/foreach}
                        </select>
                    </td>
                </tr>
                <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='0' {if !$mail.new_records_always}selected{/if}>{$lang['modules']['mail']['new_records_option0']}</option>
                            <option value='1' {if  $mail.new_records_always}selected{/if}>{$lang['modules']['mail']['new_records_option1']}</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="">
                            {foreach from = $fmail1 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail11 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail item = subtable  name=row}
                                <option style='display:none' class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                        </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="">
                            {foreach from = $fmail2 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail22 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail item = subtable  name=row}
                                <option style='display:none' class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                        </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-160" name="bmail" id="tabmail3" title="">
                            {foreach from = $fmail3 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail33 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail item = subtable  name=row}
                                <option style='display:none' class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                        </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-160" name="imail" id="tabmail4" title="">
                            {foreach from = $fmail4 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail44 item = subtable  name=row}
                                <option class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                            {foreach from = $fmail item = subtable  name=row}
                                <option style='display:none' class='field filter{$subtable.table_id}'
                                        value='{$subtable.id}'>{$subtable.name_field}</option>
                            {/foreach}
                        </select>
                    </td>
                </tr>
                </tbody>
            </table>
            <input type="hidden" name="users" id="uss" value="{$mail['users']}">
            <div class="clear"></div>
            <br/>
            <br/>
            <input type=hidden name="csrf" value="{$csrf}">
            <input type="hidden" name="action" value="save">
            <button class="btn btn-default btn-sm" onclick="InvalidMsg(this);" type = "submit">{$lang['modules']['mail']['insetsave']}</button>
            <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>
    </div>
</div>
<script type="text/javascript" src="{$config.site_root}/modules/mail/js/script.js?{$revision}"></script>
<script>
    $(document).ready(() => {
        init_chosen();
    });
</script>