{template "header.html"}
<div class="note note-danger">
    <p><a href="javascript:dr_update_cache_all();">{dr_lang('更改数据之后请更新下全站缓存')}</a></p>
</div>

<div class="right-card-box">
    <form class="form-horizontal" role="form" id="myform">
        {dr_form_hidden()}
        <div class="table-scrollable">
            <table class="table table-striped table-bordered table-hover table-checkable">
                <thead>
                <tr>
                    {if $ci->_is_admin_auth('del')}
                    <th class="myselect">
                        <label class="mt-table mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                            <input type="checkbox" class="group-checkable" data-set=".checkboxes" />
                            <span></span>
                        </label>
                    </th>
                    {/if}
                    <th width="70" style="text-align:center"> {dr_lang('排序')} </th>
                    <th width="270"> {dr_lang('服务器')} </th>
                    <th width="270"> {dr_lang('邮箱账号')} </th>
                    <th width="80"> {dr_lang('端口号')} </th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                {loop $list $t}
                <tr class="odd gradeX" id="dr_row_{$t.id}">
                    {if $ci->_is_admin_auth('del')}
                    <td class="myselect">
                        <label class="mt-table mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                            <input type="checkbox" class="checkboxes" name="ids[]" value="{$t.id}" />
                            <span></span>
                        </label>
                    </td>
                    {/if}
                    <td style="text-align:center"> <input type="text" onblur="dr_ajax_save(this.value, '{dr_url('email/save_edit', ['id'=>$t.id])}', 'displayorder')" value="{$t.displayorder}" class="displayorder form-control input-sm input-inline input-mini"> </td>
                    <td>{$t.host}</td>
                    <td>{$t.user}</td>
                    <td>{$t.port}</td>
                    <td>
                        {if $ci->_is_admin_auth('edit')}<a href="javascript:dr_iframe('edit', '{dr_url('email/edit', ['id'=>$t.id])}');" class="btn btn-xs green"> <i class="fa fa-edit"></i> {dr_lang('修改')} </a>{/if}
                        <a id="dr_sending_{$t.id}" href="javascript:;" onclick="test_email('{$t.id}')" class="btn btn-xs default"> <i class="fa fa-send"></i> {dr_lang('测试发送')} </a>
                    </td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
        <div class="row fc-list-footer table-checkable ">
            <div class="col-md-5 fc-list-select">
                {if $ci->_is_admin_auth('del')}
                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                    <input type="checkbox" class="group-checkable" data-set=".checkboxes" />
                    <span></span>
                </label>
                <button type="button" onclick="dr_ajax_option('{dr_url('email/del')}', '{dr_lang('你确定要删除它们吗？')}', 1)" class="btn red btn-sm"> <i class="fa fa-trash"></i> {dr_lang('删除')}</button>
                {/if}
            </div>
            <div class="col-md-7 fc-list-page">
                {$mypages}
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    function test_email(id) {
        $("#dr_sending_"+id).html(" <i class='fa fa-send'></i> {dr_lang('发送中...')}");
        $.ajax({type: "GET",dataType:"json", url: "{dr_url('api/email_test')}&id="+id+"&"+Math.random(),
            success: function(json) {
                dr_tips(json.code, json.msg, -1);
                $("#dr_sending_"+id).html(" <i class='fa fa-send'></i> {dr_lang('发送测试')}");
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError)
            }
        });
    }
</script>
{template "footer.html"}