<?php defined('InShopNC') or exit('Access Invalid!');?>
<style>
    input {
        width: 270px;
    }
</style>
<div class="page">
    <!-- 页面导航 -->
    <div class="fixed-bar">
        <div class="item-title">
            <h3><?php echo $output['item_title'];?></h3>
            <ul class="tab-base">
                <?php   foreach($output['menu'] as $menu) {  if($menu['menu_key'] == $output['menu_key']) { ?>
                    <li><a href="JavaScript:void(0);" class="current"><span><?php echo $menu['menu_name'];?></span></a></li>
                <?php }  else { ?>
                    <li><a href="<?php echo $menu['menu_url'];?>" ><span><?php echo $menu['menu_name'];?></span></a></li>
                <?php  } }  ?>
            </ul>
        </div>
    </div>
    <div class="fixed-empty"></div>
    <form method="post" id="serch_special">
        <input type="hidden" name="form_submit" value="ok">
        <table class="tb-type1 noborder search">
            <tbody>
            <tr style="background: rgb(255, 255, 255);">
                <td>
                    <label>专题ID：<input type="text" name="search_special_id"></label>
                </td>
                <td>
                    <label>专题描述：<input type="text" name="special_desc"></label>
                </td>
                <td>
                    <select name="state_sel">
                        <option value="">请选择...</option>
                        <option value="1">发布未审核</option>
                        <option value="2">审核未通过</option>
                        <option value="3">审核通过</option>
                        <option value="4">全部</option>
                    </select>
                </td>
                <td>
                    <a href="javascript:void(0);" id="ncsubmit" class="btn-search" title="查询">&nbsp;</a>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
    <script type="text/javascript">
        $(function(){
            $('#ncsubmit').on('click',function(){
                $('#serch_special').submit();
            });
        })
    </script>
    <!-- 帮助 -->
    <table class="table tb-type2" id="prompt">
        <tbody>
        <tr class="space odd">
            <th colspan="12" class="nobg"> <div class="title nomargin">
                    <h5><?php echo $lang['nc_prompts'];?></h5>
                    <span class="arrow"></span> </div>
            </th>
        </tr>
        <tr>
            <td><ul>
                    <li>点击添加专题按钮可以添加新的专题，专题描述可以点击后直接修改</li>
                    <li>点击编辑按钮对专题内容进行修改</li>
                    <li>点击删除按钮可以删除整个专题</li>
                </ul></td>
        </tr>
        </tbody>
    </table>
    <!-- 列表 -->
    <form id="list_form" method="post">
        <table class="table tb-type2">
            <thead>
            <tr class="space">
                <th colspan="15" class="nobg"><?php echo $lang['nc_list'];?></th>
            </tr>
            <tr class="thead">
                <th>编号</th>
                <th>标题</th>
                <th>用户ID</th>
                <th>昵称</th>
                <th>评论数</th>
                <th>点击数</th>
                <th>点赞数</th>
                <th>启用打赏</th>
                <th>打赏数</th>
                <th>打赏金额</th>
                <th>状态</th>
                <th>发布时间</th>
                <th class="w200 align-center"><span><?php echo $lang['nc_handle'];?></span></th>
            </tr>
            </thead>
            <tbody id="treet1">
            <?php if(!empty($output['list']) && is_array($output['list'])){ ?>
                <?php foreach($output['list'] as $key => $value){ ?>
                    <tr class="hover">
                        <td><?php echo $value['special_id'];?></td>
                        <td><span nc_type="edit_special_desc" column_id="<?php echo $value['special_id'];?>" title="<?php echo $lang['nc_editable'];?>" class="tooltip w270"><?php echo $value['special_desc'];?></span></td>
                        <td><?php echo $value['member_id'];?></td>
                        <td><?php echo $value['nickname'];?></td>
                        <td><?php echo $value['comments'];?></td>
                        <td><?php echo $value['clicks'];?></td>
                        <td><?php echo $value['likes'];?></td>
                        <td><?php echo $value['appreciate'] == 1 ? '是' : '否';?></td>
                        <td><?php echo $value['appreciates'];?></td>
                        <td><?php echo $value['appreciate_amonut'];?></td>
                        <td><?php
                            $state   = $value['state'];
                            $checked = $value['check_time'] == 0 ? false : true;
                            if($checked)
                            {
                                if($state == 1) {
                                    $tag = '审核拒绝';
                                } else {
                                    $tag = '审核通过';
                                }
                            }
                            else
                            {
                                if($state == 1) {
                                    $tag = '预览未审核';
                                } else {
                                    $tag = '发布未审核';
                                }
                            }
                            echo $tag;
                        ?></td>
                        <td><?php echo strftime('%Y-%m-%d:%I:%M',$value['pubtime']);?></td>
                        <td class="nowrap align-center">
                            <a target="_blank" href="<?php echo BASE_SITE_URL . "/mobile/index.php?act=special&op=index&special_id={$value['special_id']}&client_type=wap";?>">预览</a> |
                            <a href="<?php echo BASE_SITE_URL . "/admin/index.php?act=mb_special&op=check_ugc&state=pass&special_id={$value['special_id']}&client_type=wap";?>">审核通过</a> |
                            <a href="<?php echo BASE_SITE_URL . "/admin/index.php?act=mb_special&op=check_ugc&state=unpass&special_id={$value['special_id']}&client_type=wap";?>">审核拒绝</a>
                        </td>
                    </tr>
                <?php } ?>
            <?php }else { ?>
                <tr class="no_data">
                    <td colspan="16"><?php echo $lang['nc_no_record'];?></td>
                </tr>
            <?php } ?>
            <tr style="background: none repeat scroll 0% 0% rgb(255, 255, 255);">
                <td colspan="20"><a id="btn_add_mb_special" href="javascript:;" class="btn-add marginleft">添加专题</a></td>
            </tr>
            </tbody>
            <?php if(!empty($output['list']) && is_array($output['list'])){ ?>
                <tfoot>
                <tr class="tfoot">
                    <td colspan="16"><div class="pagination"> <?php echo $output['page'];?> </div></td>
                </tr>
                </tfoot>
            <?php } ?>
        </table>
    </form>
</div>
<form id="del_form" action="<?php echo urlAdmin('mb_special', 'special_del');?>" method="post">
    <input type="hidden" id="del_special_id" name="special_id">
</form>
<div id="dialog_add_mb_special" style="display:none;">
    <form id="add_form" method="post" action="<?php echo urlAdmin('mb_special', 'special_save');?>">
        <table class="table tb-type2">
            <tbody>
            <tr class="noborder">
                <td colspan="2" class="required"><label class="validation" for="special_desc">专题描述<?php echo $lang['nc_colon'];?></label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" value="" name="special_desc" class="txt"></td>
                <td class="vatop tips">专题描述，最多20个字</td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="2"><a id="submit" href="javascript:void(0)" class="btn"><span><?php echo $lang['nc_submit'];?></span></a></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/jquery.ui.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.edit.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        //添加专题
        $('#btn_add_mb_special').on('click', function() {
            $('#dialog_add_mb_special').nc_show_dialog({title: '添加专题'});
        });

        //提交
        $("#submit").click(function(){
            $("#add_form").submit();
        });

        $('#add_form').validate({
            errorPlacement: function(error, element){
                error.appendTo(element.parents('tr').prev().find('td:first'));
            },
            rules : {
                special_desc : {
                    required : true,
                    maxlength : 20
                }
            },
            messages : {
                special_desc : {
                    required : "专题描述不能为空",
                    maxlength : "专题描述最多20个字"
                }
            }
        });

        //删除专题
        $('[nctype="btn_del"]').on('click', function() {
            if(confirm('确认删除?')) {
                $('#del_special_id').val($(this).attr('data-special-id'));
                $('#del_form').submit();
            }
        });

        //编辑专题描述
        $('span[nc_type="edit_special_desc"]').inline_edit({act: 'mb_special',op: 'update_special_desc'});
    });
</script>
