<?php

/*
 * ----------------------------------------------------
 * 程序名称: 牛叉广告管理系统(NiuXams)
 * 程序功能: 实现专业的广告投放、管理和统计等管理系统！
 * 程序开发: 牛叉软件(NiuXSoft.com)
 * 版权所有: [NiuXams] (C)2013-2099 NiuXSoft.com
 * 官方网站: www.niuxsoft.com  Email: niuxsoft@163.com
 * ----------------------------------------------------
 * 使用条款:
 * 1.为构建创新型经济社会,请尊重保护知识产权！
 * 2.该软件个人非商业用途免费使用.
 * 3.免费使用禁止修改版权信息和官方推广链接.
 * 4.禁止任何衍生版本.禁止任何非法修改源代码贩卖.
 * ----------------------------------------------------
 */

defined('NIUX_INCLUDED') or exit('Access Denied.');

require './mo_head.php';
?>
<style>
    h3 {
        width: 14em;
        padding: .3em;
    }
    .text {
        width: 24em;
        font-size: 1em;
        padding: .6em;
    }
    select{
        width: 18em;
    }
    .tip {
        margin-left: 12px;
        padding: .3em;
        display: inline-block;
    }
</style>
<script>
    $(function () {
        function show_powerLbSelect() {
            if ($("#powerLbSelect").val() == 1) {
                $("#qun").show();
            } else {
                $("#qun").hide();
            }
        }
        show_powerLbSelect();
        $("select").selectmenu();
        $("#powerLbSelect").selectmenu({
            change: function (event, data) {
                show_powerLbSelect();
            }
        });
        $("#submit").click(function () {
            if (checkInput('#name', /^([0-9a-zA-Z@._]){3,20}$/) && checkInput('#pwd', /^(\S){<?php echo $id ? 0 : 6; ?>,40}$/)) {
                loading();
                $.ajax({
                    type: "POST",
                    url: location.href,
                    data: {
                        menu: "submit",
                        name: $("#name").val(),
                        pwd: $("#pwd").val(),
                        powerSelect: $("#powerSelect").val(),
                        powerLbSelect: $("#powerLbSelect").val(),
                        lbSelect: $("#lbSelect").val()
                    },
                    success: function (msg) {
                        loaded();
                        if (msg == "1") {
                            dialog('恭喜你，添加成功！是否继续添加？', 1, location.href);
                        } else if (msg == "2") {
                            dialog('恭喜你，修改成功！是否继续修改？', 1, location.href);
                        } else {
                            dialog(msg);
                        }
                    }
                });
            }
        });
    });
</script>
<div class="fullScreen">
    <h2 class="ptb hd ui-widget-content"><?php echo $title ?></h2>
    <div class="plr ptb">
        <h3 class="fl">用户登录名</h3>
        <input class="text fl ui-widget-content ui-corner-all" id="name" value="<?php echo htmlspecialchars($name) ?>" placeholder="">
        <span class="tip clear">* 3-20个字符的字母、数字、@._的组合</span>
    </div>
    <div class="plr ptb">
        <h3 class="fl">用户登录密码</h3>
        <input class="text fl ui-widget-content ui-corner-all" id="pwd" value="" placeholder="<?php echo $id ? '不填表示不修改，修改需要输入大于5位的新密码。' : '' ?>">
        <span class="tip clear">* 6-40个各种字符的组合</span>
    </div>
    <div class="plr ptb">
        <h3 class="fl">权限组</h3>
        <select id="powerSelect" name="powerSelect" class="ui-widget-content ui-corner-all"><?php echo $powerSelect ?></select>
        <span class="tip clear"></span>
    </div>
    <div class="plr ptb">
        <h3 class="fl">权限等级</h3>
        <select id="powerLbSelect" name="powerLbSelect" class="ui-widget-content ui-corner-all"><?php echo $powerLbSelect ?></select>
        <span class="tip clear"></span>
    </div>
    <div class="plr ptb hide" id="qun">
        <h3 class="fl">群</h3>
        <select id="lbSelect" name="lbSelect" class="ui-widget-content ui-corner-all"><?php echo $lbSelect ?></select>
        <span class="tip clear"></span>
    </div>
    <div class="ptb hd ui-widget-content"></div>
    <div class="plr ptb">
        <h3 class="fl"></h3>
        <button type="button" class="button" id="submit"> 完 成 </button>
        <span class="tip clear"></span>
    </div>
</div>
<?php
require './mo_foot.php';

