<style type="text/css">
.m_table_box  table td .aa {
    text-align: center;
    background: transparent;
}
</style>
<div class="col-md-10" role="main">
    <nav class="breadcrumb"></i> 分享圈<span class="c-gray en">&gt;</span>全部话题管理</nav>
    <div class="title-box">
        <p class="t-p"  style="font-size: 28px; color: #7d7d7d;vertical-align: middle; padding-top: 15px; padding-bottom: 15px;">全部话题</p>
        <div class="t-e" style="margin-left:30px">
            <img src="assets/images/explain.png" alt="">
            <span>说明：① 本站话题均在此展示，可点击加入推荐将话题展示在客户端的话题列表中，并在后台“推荐话题”中管理,云话题为Mocuz云端下发的话题，<br/>站长自建为站长在V3后台新建的话题，用户自建为用户在客户端创建的话题，分享圈发帖时使用#话题#即可创建</span>
        </div>
    </div>
    
    <div class="topic_box">
        <form method='post' action='<?php echo site_url('sharecircle/topic/all_topic');?>' id='search' >
            <div class="screening">
                <div class="topic_group">
<!--                     <div class="topic_group_left">
                        <div class="gn_jf_type topic_select">
                            <p class="reward_je_p" id="type_search"><?php if(empty($type_name_search)){echo '按话题类型查询';}else{echo $type_name_search;}?></p>
                            <img src="<?php echo asset_url('images/triangle.png')?>" alt="" class="sel_down">
                        </div>
                        <ul isn="0"  class="topic_select_option">
                            <?php if (!empty($topic_type)):?>
                            <?php foreach ($topic_type as $value) :?>
                            <li class="on_tc_type" vid="<?php echo $value['id']?>"><?php echo $value['tname']?></li>
                            <?php endforeach; endif; ?>
                        </ul>
                        <input name="type_search" type="hidden" value="<?php if(!empty($_POST['type_search'])){echo $_POST['type_search'];}elseif(!empty($val['type_search'])){echo $val['type_search'];}?>"/>
                    </div> -->
                    <div class="topic_group_left">
                        <input type="text" class="form-control topic_group_gjz" name="keywords_search" value="<?php if(!empty($_POST['keywords_search'])){echo $_POST['keywords_search'];}elseif(!empty($val['keywords_search'])){echo $val['keywords_search'];}?>" placeholder="按关键字查询">
                        <img src="<?php echo asset_url('images/search.png')?>" alt="" class="topic_group_gjz_img">
                    </div>   
                    <input onclick="location.href='<?php echo site_url('sharecircle/topic/new_topic');?>'" type="button" type="button" value="新建" class="topic_group_input"/>
                </div>
               
                <div class="topic_group">
                     <div class="topic_group_left">
                        <div class="gn_jf_type topic_select">
                            <p class="reward_je_p" id="source_search"><?php if(empty($source_name_search)){echo '按话题来源查询';}else{echo $source_name_search;}?></p>
                            <img src="<?php echo asset_url('images/triangle.png')?>" alt="" class="sel_down">
                        </div>
                        <ul isn="0"  class="topic_select_option">
                            <li class="on_tc_type" vid="1">站长自建</li>
                            <li class="on_tc_type" vid="2">云话题</li>
                            <li class="on_tc_type" vid="3">用户自建</li>
                             <li class="on_tc_type" vid="4">全部</li>
                        </ul>
                        <input name="source_search" type="hidden" value="<?php if(!empty($_POST['source_search'])){echo $_POST['source_search'];}elseif(!empty($val['source_search'])){echo $val['source_search'];}?>" />
                    </div>
                    <input type="submit"  type="button" value="查询" class="topic_group_input"/>
                    
                </div>

                <div class="topic_group">
                    <div class="topic_group_left">
                        <input name="stime_search" type="text" class="datepicker  form-control dateinput topic_group_gjz" value="<?php if(!empty($_POST['stime_search'])){echo $_POST['stime_search'];}elseif(!empty($val['stime_search'])){echo $val['stime_search'];}?>" placeholder="选择话题时间区间"/>&nbsp;&nbsp;至&nbsp;&nbsp;
                        <input name="etime_search" type="text" class="datepicker  form-control dateinput topic_group_gjz" value="<?php if(!empty($_POST['etime_search'])){echo $_POST['etime_search'];}elseif(!empty($val['etime_search'])){echo $val['etime_search'];}?>" placeholder="选择话题时间区间"/>
                    </div>
                    <input  id="topic_del" type="button" value="删除" class="topic_group_input"/>
                </div>
            </div>
        </form>
        <div class="m_table_box topic_table" >
            <table>
                <thead>
                <tr>
                    <th class="s-thead"></th>
                    <th class="s-thead">话题ID</th>
                    <th class="s-thead">话题内容</th>
                   <!--  <th class="s-thead">话题类型</th> -->
                    <th class="s-thead">话题来源</th>
                    <th class="s-thead">创建时间</th>
                    <th class="s-thead">页显人气</th>
                    <th class="s-thead">话题人气</th>
                    <th class="s-thead">参与人数</th>
                    <th class="s-thead">关注人数</th>
                    <th class="s-thead">管理</th>
                </tr>
                </thead>
                <tbody>
                    <?php if (!empty($topic_list)):?>
                    <?php foreach ($topic_list as $value) :?>
                    <tr>
                        <td><img src="<?php echo asset_url('images/select_box.png')?>" alt="" class="biu_rdo_img " isc="0" tid="<?php echo $value['id'];?>"></td>
                        <td><?php echo $value['id'];?></td>
                        <!-- <td onclick="update_topic(<?php echo $value['id'];?>,'<?php echo $fenyelist;?>'');"><?php echo $value['title'];?></td> -->
                        <td>
                          <form id="form1" method="post" action="<?php echo site_url('sharecircle/topic/update_topic')?>">
                            <input type="submit" class='aa'  value="<?php echo $value['title'];?>">
                            <input type="hidden" name="tid" value="<?php echo $value['id'];?>">
                            <input type="hidden" id="fenyechuansan" name="fenye" value='<?php echo $fenyelist;?>'>
                            </form>
                        </td>
                        <!-- <td><?php echo $value['type_name'];?></td> -->
                        <td><?php echo $value['source_name'];?></td>
                        <td><?php echo $value['create_time'];?></td>
                        <td><?php echo $value['extracount'];?></td>
                        <td><?php echo $value['buzzcount'];?></td>
                        <td><?php echo $value['involcount'];?></td>
                        <td><?php echo $value['concerncount'];?></td>
                        <td id="rec_<?php echo $value['id'];?>">
                            <?php if ($value['isrec'] == 1){echo '已推荐';} else {?>
                            <button class="topic_table_btn" tid="<?php echo $value['id'];?>">加入推荐</button>
                            <?php }?>
                        </td>
                    </tr>
                    <?php endforeach; endif; ?>
                </tbody>
            </table>

        </div>
        <?php echo $pageinfo;?>
    </div>
</div>
<script type="text/javascript" src="<?php echo asset_url('js/bootstrap-datepicker.js') ?>"></script>
<script type="text/javascript" src="<?php echo asset_url('js/validate.js') ?>"></script>
<script type="text/javascript" src="<?php echo asset_url('js/bootstrapValidator.min.js') ?>"></script>
<script type="text/javascript" src="<?php echo asset_url('js/common.js') ?>"></script>
<script type="text/javascript">
$(function(){
    // 模拟下拉框
    $('.gn_jf_type').click(function(e){
        e.stopPropagation();
        var ul=$(this).next('.topic_select_option');
        var isn=ul.attr('isn');
        if(isn==0){
            ul.show();
            ul.attr('isn','1');
            $('.gn_jf_type').not($(this)).siblings('ul').hide();
            $('.gn_jf_type').not($(this)).siblings('ul').attr('isn','0');
        }else{
            ul.hide();
            ul.attr('isn','0');
        }
    });

    //点击推荐
    $('.topic_table_btn').click(function() {
        var tid = $(this).attr('tid');
        $.ajax({
            url: "<?php echo site_url('sharecircle/topic/recommend_topic')?>",
            type: 'POST',
            dataType: 'json',
            data: {tid: tid},
            success:function(data)
            {
                $('#rec_' + tid).text('已推荐');
            }
        })
    });

    //删除
    $('#topic_del').click(function(e) {
        var ids = '';
        if(confirm("确定要删除吗？")) {
            $('.biu_rdo_img').each(function() {
                if ($(this).attr('isc') == 1) {
                    if (ids === '') {
                        ids += $(this).attr('tid');
                    } else {
                        ids += ',' + $(this).attr('tid');
                    }
                }
            });
            if (ids === '') {
                alert('请选择要删除的话题');
                return false;
            } else {
                $.ajax({
                    url: "<?php echo site_url('sharecircle/topic/del_topic')?>",
                    type: 'POST',
                    dataType: 'json',
                    data: {tids: ids},
                    success:function(data)
                    {
                        location.href="<?php echo site_url('sharecircle/topic/all_topic')?>";
                    }
                })
            }
        }
    });

    $('.topic_select_option li').mouseover(function(){
        $(this).addClass('on_rk_type');
        $(this).siblings().removeClass('on_rk_type');
    })

    $('.topic_select_option li').click(function(){
        var vid = $(this).attr('vid');
        $(this).parent().next().val(vid);
        $('.topic_select_option').hide();
        $('.topic_select_option').attr('isn','0');
        var text=$(this).text();
       $(this).parent().prev().find('.reward_je_p').text(text);
    })

     // 单选按钮切换
    $('.biu_rdo_img').click(function(){
        var isc=$(this).attr('isc');
        if(isc==0){
            $(this).attr('src','<?php echo asset_url('images/selected_box.png')?>');
            $(this).attr('isc','1');
        }else{
            $(this).attr('src','<?php echo asset_url('images/select_box.png')?>');
            $(this).attr('isc','0');
        }
    });

    /*$("form").submit(function(e){
        alert('kkk');
        alert($('#ul_type').find('.on_rk_type').attr(vid));
        $("input[name=type_search]").val($('#ul_type').find('.on_rk_type').attr(vid));
        $("input[name=source_search]").val($('#ul_source').find('.on_rk_type').attr(vid));
    });*/

});
    function update_topic(tid) {
        location.href="<?php echo site_url('sharecircle/topic/update_topic/" + tid + "')?>";
    }
</script>
