<?php 
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/5/005 
 * Time: 10:16
 */
?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-12">
    <h2>系统设置</h2>
        <ol class="breadcrumb">
            <li>
                <a href="<?= \yii\helpers\Url::to(['/admin/dashboard'])?>">管理首页</a>
            </li>
            <li class="active">
                <strong>系统参数设置</strong>
            </li>
        </ol>
    </div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
    <form id="form" class="form-horizontal">
        <input type="hidden" name="id" value="<?= $config['id'] ?>">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-title">
                        <button class="btn btn-link">系统参数设置</button>
                        <div class="pull-right">
                            <a class="btn btn-default" href="<?= \yii\helpers\Url::to(['/admin/druid']) ?>" target="_blank">数据库监控</a>
                            <div id="clear" class="btn btn-default">清除缓存（谨慎）</div>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <table class="table table-bordered">
                            <tr>
                                <th>系统名称</th>
                                <td><input name="sys_name" type="text" class="form-control" value="<?= !empty($config['sys_name']) ? $config['sys_name'] : '' ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>用户协议</th>
                                <td>
                                    <div class="btn btn-group">
                                        <div id="agreement" class="btn btn-default">用户协议</div>
                                    </div>
                                </td>
                                <td>点击按钮编辑</td>
                            </tr>
                            <tr>
                                <th>邮件模板</th>
                                <td>
                                    <div class="btn btn-group">
                                        <div id="mail_open" class="btn btn-default">用户开户成功通知</div>
                                        <div id="mail_same_account" class="btn btn-default">同名开户成功通知</div>
                                        <div id="mail_ib_open" class="btn btn-default">代理开户成功通知</div>
                                        <div id="mail_code" class="btn btn-default">邮件验证码</div>
                                        <div id="mail_deposit" class="btn btn-default">入金成功通知</div>
                                        <div id="mail_reject_apply" class="btn btn-default">开户拒绝通知</div>
                                    </div>
                                </td>
                                <td>点击按钮编辑</td>
                            </tr>
                            <tr>
                                <th>杠杆</th>
                                <td><input name="lever" type="text" class="form-control" value="<?= !empty($config['lever']) ? $config['lever'] : '' ?>"></td>
                                <td>用户可用杠杆，多个请用,号分割，默认：100,200,300,400,500</td>
                            </tr>
                            <!--<tr>
                                <th>发件人邮箱</th>
                                <td><input name="smtp_from_mail" type="text" class="form-control" value="<?= $config['smtp_from_mail'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>SMTP服务器</th>
                                <td><input name="smtp_server" type="text" class="form-control" value="<?= $config['smtp_server'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>SMTP端口</th>
                                <td><input name="smtp_port" type="number" class="form-control" value="<?= $config['smtp_port'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>SMTP用户名</th>
                                <td><input name="smtp_username" type="text" class="form-control" value="<?= $config['smtp_username'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>SMTP密码</th>
                                <td><input name="smtp_password" type="password" class="form-control" value="<?= $config['smtp_password'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>是否启用SSL</th>
                                <td><input name="smtp_is_ssl" type="number" class="form-control" value="<?= $config['smtp_is_ssl'] ?>"></td>
                                <td>0表示不启用,1表示启用</td>
                            </tr>

                            <tr>
                                <th>聚合短信接口KEY</th>
                                <td><input name="juhe_sms_key" type="text" class="form-control" value="<?= $config['juhe_sms_key'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>聚合短信接口验证码模板ID</th>
                                <td><input name="juhe_sms_tpl_id" type="number" class="form-control" value="<?= $config['juhe_sms_tpl_id'] ?>"></td>
                                <td>模板内容：您的验证码是#code#。如非本人操作，请忽略本短信</td>
                            </tr>
                            <tr>
                                <th>聚合短信接口MT4账户开通模板ID</th>
                                <td><input name="juhe_sms_mt4_tpl_id" type="number" class="form-control" value="<?= $config['juhe_sms_mt4_tpl_id'] ?>"></td>
                                <td>模板内容：尊敬的#name#，您的交易账户已开立。请妥善保管您的账户：#login#和密码：#pwd#。建议您尽快更改密码</td>
                            </tr>
                            <tr>
                                <th>聚合短信接口系统账户开通模板ID</th>
                                <td><input name="juhe_sms_reg_tpl_id" type="number" class="form-control" value="<?= $config['juhe_sms_reg_tpl_id'] ?>"></td>
                                <td>模板内容：尊敬的#name#，您的管理账户已开立。请妥善保管您的账户：#login#和密码：#pwd#。建议您尽快更改密码</td>
                            </tr>-->
                            <tr>
                                <th>FOREX货币对</th>
                                <td><input name="forex_symbols" type="text" class="form-control" value="<?= $config['forex_symbols'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>CFD货币对</th>
                                <td><input name="cfd_symbols" type="text" class="form-control" value="<?= $config['cfd_symbols'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>METAL货币对</th>
                                <td><input name="metal_symbols" type="text" class="form-control" value="<?= $config['metal_symbols'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>黄金货币对</th>
                                <td><input name="xau_symbols" type="text" class="form-control" value="<?= $config['xau_symbols'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>白银货币对</th>
                                <td><input name="xag_symbols" type="text" class="form-control" value="<?= $config['xag_symbols'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>股指货币对</th>
                                <td><input name="stock_symbols" type="text" class="form-control" value="<?= $config['stock_symbols'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>BTC货币对</th>
                                <td><input name="btc_symbols" type="text" class="form-control" value="<?= $config['btc_symbols'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>是否开启自动入金</th>
                                <td>
                                    <input type="radio" name="auto_deposit"  value="1" <?php if($config['auto_deposit'] == 1): ?>checked<?php endif;?> /> 开启
                                    <input type="radio" name="auto_deposit"  value="0" <?php if($config['auto_deposit'] == 0): ?>checked<?php endif;?>/> 关闭


                                </td>
                                <td></td>
                            </tr>
                            <!--<tr>
                                <th>银行列表</th>
                                <td><input name="banks" type="text" class="form-control" value="<?= $config['banks'] ?>"></td>
                                <td>多个用","号分割</td>
                            </tr>
                            <tr>
                                <th>MT4 Manager IP</th>
                                <td><input name="mt4_manager_ip" type="text" class="form-control" value="<?= $config['mt4_manager_ip'] ?>"></td>
                                <td></td>
                            </tr>-->
                            <tr>
                                <th>MT4开户IP</th>
                                <td><input name="mt4_manager_ip" type="text" class="form-control" value="<?= $config['mt4_manager_ip'] ?>"></td>
                                <td></td>
                            </tr>
                            <tr>
                                <th>MT4开户IP端口</th>
                                <td><input name="mt4_manager_port" type="text" class="form-control" value="<?= $config['mt4_manager_port'] ?>"></td>
                                <td></td>
                            </tr>

                            <!--<tr>
                                <th>MT4 组</th>
                                <td>
                                    <input id="groups" name="mt4_groups" type="text" class="form-control" value="<?= $config['mt4_groups'] ?>">
                                </td>
                                <td>
                                    <span class="btn btn-default" onclick="getG()">重新获取组</span>
                                </td>
                            </tr>
                            <tr>
                                <th>订单开始统计日期</th>
                                <td><input name="end_his_trade_time" type="text" class="form-control data" value="<?= date('Y-m-d', strtotime($config['end_his_trade_time'])) ?>"></td>
                                <td>日期之前记录会删除,更改后请清除缓存</td>
                            </tr>
                            <tr>
                                <th>订单返佣开始计算日期</th>
                                <td><input name="commission_deal_time" type="text" class="form-control data" value="<?= date('Y-m-d', strtotime($config['commission_deal_time'])) ?>"></td>
                                <td>需重启TOMCAT才会生效</td>
                            </tr>-->

                        </table>

                    </div>
                    <div class="ibox-footer">
                        <button id="submit" type="button" class="btn btn-primary"> 点我更新  ← 请谨慎设置</button>
                    </div>
                </div>
            </div>

        </div>
    </form>
</div>

<?php $this->beginBlock('footer_script'); ?>
<script>
    KindEditor.ready(function(K) {});
</script>

<!-- Page-Level Scripts -->
<script>

    $("#submit").on("click", function() {
        $.ajax({
            type: "POST",
            url: "/admin/config/update",
            data: $('#form').serialize(),
            dataType: "json",
            beforeSend: function() {},
            success: function(data) {
                if(data.code) {
                    toastr.success(data.message, "提示");
                } else {
                    toastr.error(data.message, "提示");
                }
            },
            complete: function(XMLHttpRequest, textStatus) {},
            error: function() {}
        });
    });

    function getG(){
        $.ajax({
            type: "POST",
            url: "/admin/mt4/group",
            data: $('#form').serialize(),
            dataType: "text",
            beforeSend: function() {},
            success: function(data) {
                $("#groups").val(data);
            },
            complete: function(XMLHttpRequest, textStatus) {},
            error: function() {}
        });

    }

    $("#clear").on("click", function() {
        $.ajax({
            type: "POST",
            url: "/admin/config/clear-cache",
            data: $('#form').serialize(),
            dataType: "json",
            beforeSend: function() {},
            success: function(data) {
                toastr.success(data.message, "提示");
            },
            complete: function(XMLHttpRequest, textStatus) {},
            error: function() {}
        });
    });

    $('.data').datepicker({
        startView: 1,
        todayBtn: "linked",
        keyboardNavigation: true,
        forceParse: false,
        autoclose: true,
        format: "yyyy-mm-dd"
    });

    $('#mail_code').click(function() {
        $("#modal").removeData();
        var url="/admin/config/edit?t=mail_code";
        $("#modal").modal({
            remote:url,
            show:true
        });
    });
    $('#mail_open').click(function() {
        $("#modal").removeData();
        var url="/admin/config/edit?t=mail_open";
        $("#modal").modal({
            remote:url,
            show:true
        });
    });
    $('#mail_same_account').click(function() {
        $("#modal").removeData();
        var url="/admin/config/edit?t=mail_same_account";
        $("#modal").modal({
            remote:url,
            show:true
        });
    });
    $('#mail_ib_open').click(function() {
        $("#modal").removeData();
        var url="/admin/config/edit?t=mail_ib_open";
        $("#modal").modal({
            remote:url,
            show:true
        });
    });
    $('#mail_deposit').click(function() {
        $("#modal").removeData();
        var url="/admin/config/edit?t=mail_deposit";
        $("#modal").modal({
            remote:url,
            show:true
        });
    });
    $('#mail_reject_apply').click(function() {
        $("#modal").removeData();
        var url="/admin/config/edit?t=mail_reject_apply";
        $("#modal").modal({
            remote:url,
            show:true
        });
    });

    $('#agreement').click(function() {
        $("#modal").removeData();
        var url="/admin/config/edit?t=agreement";
        $("#modal").modal({
            remote:url,
            show:true
        });
    });


</script>
<?php $this->endBlock(); ?>
