<?php
/*
 * @Team : 孜然云
 * @Author : 孜然
 * @Url : zrv7.com
 * @Date : 2022-01-05 00:55
 * @Project : 孜然授权系统
 * @Description : 基于ZR框架开发的授权系统
 * @Qq : 2937978586
 * @Wx : hhr2937978586 
 * @Email : 2937978586@qq.com
 * @Read me : 孜然授权系统，是一款多模板/多用途/多权限的授权系统
 * @Remind : 孜然授权系统受《劳动知识产权》和《计算机软件著作法》的法律保护，使用破解即违法法律
 * @Dbfk : 如果您已经使用了盗版，孜然可以通过上述两法告你，不过我是不会这么做的，如果是传播盗版那么就必定告上法院
 */
$id=isset($_GET['id'])?$_GET['id']:null;
?>
<?php
if($id=='add'){
$title='添加通知';
require_once 'head.php';
?>
 <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-header">发布通知</div>
        <div class="layui-card-body">
            <form class="layui-form layui-form-pane" id="formBasForm" lay-filter="formBasForm">
                            
                <div class="layui-form-item">
                    <label class="layui-form-label">通知标题</label>
                    <div class="layui-input-block">
                    <input type="text" name="title" placeholder="请输入标题[必填]" class="layui-input" />
                    </div>
                </div>

               <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">通知内容</label>
                    <div class="layui-input-block">
                    <textarea class="layui-textarea" name="content" placeholder="请输入内容[必填]"></textarea>
                    </div>
                </div>                

                    <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">通知类型</label>
                    <div class="layui-input-block">
                    <select class="layui-input" name="leixing" lay-filter="leixing">
                    <option value="">请选择所通知类型</option>
                    <option value="1">注册用户</option>
                    <option value="2">授权域名</option>
                    <option value="3">盗版站点</option>
                    </select>
                    </div>
                    </div> 

                    <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">通知程序</label>
                    <div class="layui-input-block">
                    <select class="layui-input" name="procedure">
                    <?php
                    $ZR=$DB->query("SELECT * FROM zrauth_procedure WHERE type=1 order by id asc");
                    while($row = $DB->fetch($ZR))
                    {
                    ?>
                    <option value="<?php echo $row['id'];?>"><?php echo $row['name'];?></option>
                    <?php } ?>                    
                    </select>
                    </div>
                    </div> 

                    <div class="layui-form-item" pane>
                    <label class="layui-form-label">通知状态</label>
                    <div class="layui-input-block">
                    <input type="radio" name="type" value="1" title="正常" checked>
                    <input type="radio" name="type" value="0" title="封禁">
                    </div>
                    </div>

                    <div class="layui-form-item layui-row layui-col-space10 ">
                    <div class="layui-col-md2">
                    <button type="button" class="layui-btn layui-btn-fluid" lay-submit lay-filter="noticeBtn">&emsp;发布通知&emsp;</button>
                    </div>
                    <div class="layui-col-md2">
                    <button type="reset" id="formreset" class="layui-btn layui-btn-primary layui-btn-fluid">&emsp;重置表单&emsp;</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
layui.use(['form', 'element','jquery', 'admin', 'tagsInput', 'notice'], function () {
    var form = layui.form;
    var $ = layui.jquery;
    var tagsInput = layui.tagsInput;
    var admin = layui.admin;
    var notice = layui.notice;
    $('#formreset').click(function () {
        document.getElementById("formBasForm").reset();
        notice.destroy();
        notice.msg('重置表单成功！', {animateInside: true, icon: 1});
    });
    form.on('submit(noticeBtn)', function (data) {
        var title = $("input[name='title']").val();
        var content = $("textarea[name='content']").val();
        var leixing = $("select[name='leixing']").val();
        var procedure = $("select[name='procedure']").val();
        var type = $("input[name='type']:checked").val();
        admin.btnLoading('[lay-filter="noticeBtn"]',' 添加中');
        var ii = layer.load(2, {shade:[0.1,'#fff']});
        notice.destroy();
        $.ajax({
            type: "POST",
            url: "ajax/message_ajax.php?act=add",
            data : {title:title,content:content,leixing:leixing,procedure:procedure,type:type},
            dataType: "json",
            success: function(data) {
                layer.close(ii);
                admin.btnLoading('[lay-filter="noticeBtn"]', false);
                if (data.code == 0) {
                    notice.msg(data.msg, {animateInside: true, icon: 1});
                } else {
                    notice.msg(data.msg, {animateInside: true, icon: 2});
                }
            },
            error:function(data){
                notice.msg('代码错误！作者QQ2937978586', {animateInside: true, icon: 2});
                return false;
            }
        });
        return false;
    });
         form.on('select(leixing)', function(data){
            if(data.value == 1){
                $("#power").css("display","inherit");
            }else{
                $("#power").css("display","none");
            }
        });  
});
</script>
<?php } ?>