<?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: 24em;
    }
    .tip {
        margin-left: 12px;
        padding: .3em;
        display: inline-block;
    }
</style>
<script>
    $(function () {
        $("#submit").click(function () {
            if (checkInput('#pid', /^([0-9]){1,3}$/) && checkInput('#name', /^(\S){1,40}$/)) {
                loading();
                var funcSelect = '';
                $("#powerSelect option:selected").each(function () {
                    funcSelect = funcSelect + this.value + "|";
                });
                $.ajax({
                    type: "POST",
                    url: location.href,
                    data: {
                        menu: "submit",
                        pid: $("#pid").val(),
                        name: $("#name").val(),
                        powerSelect: funcSelect
                    },
                    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="pid" value="<?php echo $pid ? $pid . '" readonly' : '"' ?> placeholder="">
        <span class="tip clear">* 1-255之间的整数，数字越大权限越高。</span>
    </div>
    <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">* 1-40个各种字符的组合</span>
    </div>
    <div class="plr ptb">
        <h3 class="fl">权限组功能授权</h3>
        <select id="powerSelect" name="powerSelect" multiple="true" size="20" class="ui-widget-content ui-corner-all"><?php echo $funcSelect ?></select>
        <span class="tip clear">(按 Ctrl 或 Shift 可以进行多选)</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';
