<?php
include_once("c_setting.php");
class c_page_cab_setting_send_smtp extends c_page_cab_setting
{
    public $h1='Отправка почты (smtp) - настройки' ;

    function block_main()
    {
        if ($_POST['cmd']) $this->test_send_message($_POST['filter']);
        $this->test_send_mail();
        $this->show_setting_table();
    }

    function test_send_mail()
    {
        $member_info = ACCOUNTS()->get_member_by_id(MEMBER()->id); ?>
        <h1>Тестовая отправка сообщения</h1>
        <div id="panel_filter">
            <form class="sky-form" method="POST">
                <div class="row">
                    <section class="col col-4">
                        <label class="label">Email получателя:</label>
                        <label class="input">
                            <input type="text" name="filter[email]" value="<?echo htmlspecialchars($member_info['email'])?>" autocomplete="off">
                        </label>
                    </section>
                </div>
                <div class="row">
                    <section class="col col-4">
                        <label class="label">Заголовок сообщения:</label>
                        <label class="input">
                            <input type="text" name="filter[theme]" value="Тестовое сообщение" autocomplete="off">
                        </label>
                    </section>
                </div>
                <div class="row">
                    <section class="col col-4">
                        <label class="label">Текст сообщения:</label>
                        <label class="input">
                            <input type="text" name="filter[text]" value="" autocomplete="off">
                        </label>
                    </section>
                </div>
                <div id="panel_buttons">
                    <input name="cmd" class="button" type="submit" value="Отправить" cmd="test_send_message">
                </div>
            </form>
        </div>
        <style>
            form {padding:8px 0;}
            div#panel_buttons {text-align:left;}
        </style>
        <?
    }

    function show_setting_table()
    {
        $this->page_title() ;
        include_once(_DIR_EXT.'/aspmo_setting/c_setting_interface.php')  ;
        $page=new c_page_cab_setting_interface() ;
        $page->panel_setting('Отправка почты (smtp)',array('no_hidden_items'=>1)) ;
    }

    function test_send_message($data)
    {
        $mail_options['cc']=array() ;
        $mail_options['debug']=1;
        $mail_options['no_asyns_send_mail']=1;
        MAILS()->send_mail($data['email'],$data['theme'],$data['text'],$mail_options);
    }

}