<?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>
    .nav{
        margin: .4em 0;
        padding: .7em .3em .3em .7em;
    }
    .nav select{
        width: 9.4em;
    }
    .desc,.searchdiv{
        margin-top: .1em;
    }
    .search{
        width: 10em;
        padding: .48em .5em;
    }
    .fenye{
        padding-left: .4em;
    }
    .fenye a,.fenye span,.fenye input{
        margin-left: 1px;
        padding: .48em 2px;
    }
    .fenye a,.fenye span{
        display: inline-block;
        text-align: center;
        min-width: 1.3em;
    }
    .limit{
        width: 1.4em;
    }
    .page{
        width: 1.4em;
    }

    .list{
        padding:.2em;
    }
    .list table th{
        border-width:0px 1px 0px 0px;
        font-size:1.2em;
        line-height:2em;
    }
    .list table td{
        border-width:0px 1px 1px 0px;
        font-size: 1em;
        line-height: 1.8em;
        overflow: hidden;
    }

    .ui-tooltip {
        max-width: 1200px;
        word-break: break-all;
    }

    #del_ggw{
        top: .5em;
        left: 120px;
    }
    #del_ggw_back{
        top: .5em;
        left: 120px;
    }
    #del_ggw_real{
        top: .5em;
        left: 220px;
    }
    #dm{
        width: 400px;
        height: 80px;
        font-size: 1em;
    }
</style>
<script>
    $(function () {
        var order = '<?php echo $order ?>';
        $(".limit").blur(function () {
            $(this).parent().parent().submit();
        });
        $(".limit").keydown(function (event) {
            if (event.keyCode == 13) {
                $(this).blur();
            }
        });
        $(".page").blur(function () {
            $(this).parent().parent().submit();
        });
        $(".page").keydown(function (event) {
            if (event.keyCode == 13) {
                $(this).blur();
            }
        });
        $(".search").blur(function () {
            $(this).parent().parent().submit();
        });
        $(".search").keydown(function (event) {
            if (event.keyCode == 13) {
                $(this).blur();
            }
        });
        $(":radio").click(function () {
            $(this).parent().parent().submit();
        });
        $(".lei3").selectmenu({
            change: function (event, data) {
                setCoo("lei3", $(this).val(), 120);
                $(this).parent().parent().submit();
            }
        });
        $(".zu3").selectmenu({
            change: function (event, data) {
                setCoo("zu3", $(this).val(), 120);
                $(this).parent().parent().submit();
            }
        });
        $(".check_all").click(function () {
            if (this.checked) {
                $("input[type='checkbox']").each(function () {
                    this.checked = true;
                });
            } else {
                $("input[type='checkbox']").each(function () {
                    this.checked = false;
                });
            }
        });
        $("input[name='order']").val(order);
        $("." + order).parent().addClass("ui-state-highlight");
        $("th>a").click(function () {
            $("input[name='order']").val(this.className);
            $("form:first").submit();
        });
        $("td").hover(function () {
            $(this).parent().children("td").toggleClass("ui-state-highlight").css({"border-top-width": 0, "border-left-width": 0});
        });
        $(".ggw_tip").tooltip({
            content: function () {
                var element = $(this);
                return htmlspecialchars(element.attr("title")).replace(/\n/igm, "<br>").replace(/\s/igm, "&nbsp;");
            }
        });

        $("#del_ggw").click(function () {
            var ids = "";
            $(".check_id:checked").each(function () {
                ids += this.value + " ";
            });
            if (ids) {
                if (confirm("删除即刻生效！您确定要删除所选吗？")) {
                    loading();
                    $.ajax({
                        type: "POST",
                        url: 'ggw_del.php',
                        data: {menu: 'del_ggw', ids: ids},
                        success: function (msg) {
                            loaded();
                            if (msg == '1') {
                                dialog('删除成功！', 1, location.href);
                            } else {
                                dialog(msg);
                            }
                        }
                    });
                }
            }
        });
        $("#del_ggw_back").click(function () {
            var ids = "";
            $(".check_id:checked").each(function () {
                ids += this.value + " ";
            });
            if (ids) {
                if (confirm("还原即刻生效！您确定要还原所选吗？")) {
                    loading();
                    $.ajax({
                        type: "POST",
                        url: 'ggw_del_back.php',
                        data: {menu: 'back_ggw', ids: ids},
                        success: function (msg) {
                            loaded();
                            if (msg == '1') {
                                dialog('还原成功！', 1, location.href);
                            } else {
                                dialog(msg);
                            }
                        }
                    });
                }
            }
        });
        $("#del_ggw_real").click(function () {
            var ids = "";
            $(".check_id:checked").each(function () {
                ids += this.value + " ";
            });
            if (ids) {
                if (confirm("彻底删除将无法恢复！您确定要彻底删除所选吗？")) {
                    loading();
                    $.ajax({
                        type: "POST",
                        url: 'ggw_del_real.php',
                        data: {menu: 'real_del_ggw', ids: ids},
                        success: function (msg) {
                            loaded();
                            if (msg == '1') {
                                dialog('彻底删除成功！', 1, location.href);
                            } else {
                                dialog(msg);
                            }
                        }
                    });
                }
            }
        });
        $("#dialog_dm").dialog({
            autoOpen: false,
            width: 460,
            focus: function () {
                $("#dm").select();
            },
            buttons: {
                "复制": function () {
                    $("#dm").select();
                    if (window.clipboardData) {
                        var clipBoardContent = $("#dm").val();
                        window.clipboardData.setData("Text", clipBoardContent);
                        dialog("复制成功！");
                    } else {
                        dialog("抱歉，您的浏览器不支持，请按 Ctrl+C 复制！");
                    }
                },
                "取消": function () {
                    $(this).dialog("close");
                }
            }
        });
        $(".getDm").click(function () {
            var element = $(this);
            $('#dialog_dm').dialog("option", "position", {my: "right top", at: "left top", of: element}).dialog("open");
            $("#dm").val('<script src="<?php echo $cfg_amsUrl . '/' . $cfg_output . '/' ?>' + element.attr("id") + '.js"><\/script>').select();
        });
    });
</script>
<div class="fullScreen">

    <div class="ptb hd rePos ui-widget-content">
        <button class="button absPos<?php echo $recycle ? ' hide' : '' ?>" id="del_ggw" title="删除选择的广告位">删除广告位</button>
        <button class="button absPos<?php echo $recycle ? '' : ' hide' ?>" id="del_ggw_back" title="还原选择的广告位">还原广告位</button>
        <button class="button absPos<?php echo $recycle ? '' : ' hide' ?>" id="del_ggw_real" title="彻底删除选择的广告位">彻底删除广告位</button>
        <h2 class=""><?php echo $title ?></h2>
    </div>

    <div class="nav ui-widget-content ui-corner-all">
        <form method="get">
            <div class="fl"><?php echo $leizu ?></div>
            <div class="desc buttonset fl">
                <input type="radio" id="desc1" value="1" name="desc"<?php echo ($desc ? '' : ' checked="checked"') ?>><label for="desc1" title="升序排列">升</label>
                <input type="radio" id="desc2" value="0" name="desc"<?php echo ($desc ? ' checked="checked"' : '') ?>><label for="desc2" title="降序排列">降</label>
            </div>
            <div class="searchdiv fl">
                <input class="search ui-widget-content ui-corner-all" name="search" title="按回车或失去焦点" value="<?php echo htmlspecialchars($search) ?>" placeholder="输入搜索内容">
            </div>
            <div class="fenye fl"><?php echo $fenye->result ?></div>
            <div class="clear"><input class="order" name="order" type="hidden"></div>
        </form>
    </div>

    <div class="list ui-widget-content ui-corner-all">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ui-widget-content" style="border-width:0px 0px 0px 1px;">
            <tr>
                <th class="ui-widget-header" scope="col" style="width: 1em;"><input type="checkbox" class="check_all" title="全选"></th>
                <th class="ui-widget-header" scope="col" style="width: 4em;"><a href="javascript:void(0)" class="id" title="按此排序">编号</a></th>
                <th class="ui-widget-header" scope="col"><a href="javascript:void(0)" class="title" title="按此排序">广告位名称（停留查看信息/点击预览）</a></th>
                <th class="ui-widget-header" scope="col" style="width: 3em;">修改</th>
                <th class="ui-widget-header" scope="col" style="width: 3em;">复制</th>
                <th class="ui-widget-header" scope="col" style="width: 3em;">统计</th>
                <th class="ui-widget-header" scope="col" style="width: 3em;"><a href="javascript:void(0)" class="type" title="按此排序">类型</a></th>
                <th class="ui-widget-header" scope="col" style="width: 4em;"><a href="javascript:void(0)" class="width" title="按此排序">宽(px)</a></th>
                <th class="ui-widget-header" scope="col" style="width: 4em;"><a href="javascript:void(0)" class="height" title="按此排序">高(px)</a></th>
                <th class="ui-widget-header" scope="col" style="width: 7em;">获取代码</th>
                <th class="ui-widget-header" scope="col" style="width: 8em;"><a href="javascript:void(0)" class="lei_id" title="按此排序">分类</a></th>
                <th class="ui-widget-header" scope="col" style="width: 8em;"><a href="javascript:void(0)" class="zu_id" title="按此排序">分组</a></th>
                <th class="ui-widget-header" scope="col" style="width: 8.8em;"><a href="javascript:void(0)" class="time" title="按此排序">最后修改时间</a></th>
            </tr>
            <?php echo $list ?>
            <tr>
                <th class="ui-widget-header" scope="col" style="width: 1em;"><input type="checkbox" class="check_all" title="全选"></th>
                <th class="ui-widget-header" scope="col" style="width: 4em;"><a href="javascript:void(0)" class="id" title="按此排序">编号</a></th>
                <th class="ui-widget-header" scope="col"><a href="javascript:void(0)" class="title" title="按此排序">广告位名称（停留查看信息/点击预览）</a></th>
                <th class="ui-widget-header" scope="col" style="width: 3em;">修改</th>
                <th class="ui-widget-header" scope="col" style="width: 3em;">复制</th>
                <th class="ui-widget-header" scope="col" style="width: 3em;">统计</th>
                <th class="ui-widget-header" scope="col" style="width: 3em;"><a href="javascript:void(0)" class="type" title="按此排序">类型</a></th>
                <th class="ui-widget-header" scope="col" style="width: 4em;"><a href="javascript:void(0)" class="width" title="按此排序">宽(px)</a></th>
                <th class="ui-widget-header" scope="col" style="width: 4em;"><a href="javascript:void(0)" class="height" title="按此排序">高(px)</a></th>
                <th class="ui-widget-header" scope="col" style="width: 7em;">获取代码</th>
                <th class="ui-widget-header" scope="col" style="width: 8em;"><a href="javascript:void(0)" class="lei_id" title="按此排序">分类</a></th>
                <th class="ui-widget-header" scope="col" style="width: 8em;"><a href="javascript:void(0)" class="zu_id" title="按此排序">分组</a></th>
                <th class="ui-widget-header" scope="col" style="width: 8.8em;"><a href="javascript:void(0)" class="time" title="按此排序">最后修改时间</a></th>
            </tr>
        </table>
    </div>

    <div class="nav ui-widget-content ui-corner-all">
        <form method="get">
            <div class="fl"><?php echo $leizu ?></div>
            <div class="desc buttonset fl">
                <input type="radio" id="desc3" value="1" name="desc"<?php echo ($desc ? '' : ' checked="checked"') ?>><label for="desc3" title="升序排列">升</label>
                <input type="radio" id="desc4" value="0" name="desc"<?php echo ($desc ? ' checked="checked"' : '') ?>><label for="desc4" title="降序排列">降</label>
            </div>
            <div class="searchdiv fl">
                <input class="search ui-widget-content ui-corner-all" name="search" title="按回车或失去焦点" value="<?php echo htmlspecialchars($search) ?>" placeholder="输入搜索内容">
            </div>
            <div class="fenye fl"><?php echo $fenye->result ?></div>
            <div class="clear"><input class="order" name="order" type="hidden"></div>
        </form>
    </div>

</div>

<div id="dialog_dm" title="获取一段式广告位代码：" class="hide">
    <p class="mtb mlr">一段式广告位代码：复制此代码到页面相应广告位置即可播放广告</p>
    <div class="mtb mlr">
        <textarea id="dm" class="ui-widget-content ui-corner-all"></textarea>
    </div>
</div>
<?php
require './mo_foot.php';

