<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>文章内容列表</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <include  file="Common:script"/>
    <script type="text/javascript" src="__STATIC__/assets/layer/jquery1.9.1.js?{:C('KLCHOU_BUILD')}"></script>
    <script type="text/javascript" src="__STATIC__/assets/layer/layer.js?{:C('KLCHOU_BUILD')}"></script>
         <script type="text/javascript" src="__STATIC__/js/public.js?{:C('KLCHOU_BUILD')}"></script>
    <body>
    <include file="Common:curpos"/>	
    <style>
        .table td {
            padding: 5px 16px;
        }
    </style>
 <div id="page-content">
        <div class="row fg-toolbar ui-toolbar ">
            <a class="btn medium bg-green " href="{:U('Articles/add')}">
                 <span class="button-content">添加文章</span>
            </a>
              <a class="btn medium  bg-orange delete" href="javascript:void(0)">
                 <span class="button-content">批量删除</span>
            </a>
           
        </div>
  
    
        <p class="font-gray-dark"></p>
       <form id="articles-form" method="post" action="{:U('Articles/index')}">
           
           <div class="form-row">
           
              <div class="form-input col-md-12">
                   <select id="" class="col-md-2" name="status">
                       <option value='all'>不限</option>
                       <volist name='status' id="item" k="key">
                             <option value="{$key}">{$item.text}</option>
                        </volist>
                   </select>
                 <div class="col-md-4">
                   <input id="" placeholder="请输入文章标题" name="title" type="text">
                 </div>
                 <a href="javascript:void()" class="btn large  bg-green btnSearch" title="">
                     <span class="button-content">搜索</span>
                 </a>
               </div>
        </div>  
         <div class="row">
                <table class="table">
                    <thead>
                        <tr>
                            <th><input class="check-all"  type="checkbox"   ></th>
                            <th>id</th>
                            <th>标题</th>
                            <th>栏目</th>
                            <th>录入时间</th>
                            <th>状态</th>
                            <th>评论数</th>
                            <th>阅读数</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>

                    <volist name="list"  id="item">
                        <?php  
                        if(!empty($item['flag'])){
                            $items = explode(',',$item['flag']);
                            $text ='';
                            for($i=0;$i<count($items);$i++){
                               $text .= '['.$flag[$items[$i]].']';
                            }
                        }
                        ?>
                        <tr >
                         <td><input type="checkbox" class="ids" name="ids[]" value="{$item.id}"/></td>
                        <td>{$item.id}</td>
                        <td>{$item.title}<span style="color:#fa7753 ">{$text}</span></td>
                        <td>{$item.cate_name}</td>
                        <td>{$item.inputtime|date='Ymd-His',###}</td>
                        <td class="{$status[$item['status']]['color']}">{$status[$item['status']]['text']}</td>
                        <td>{$item.comment_count}</td>
                        <td>{$item.readpoint}</td>
                        <td> 
                            <a title="" href="{:U('Articles/edit',array('id'=>$item['id']))}" data-placement="top" class="btn medium ui-state-default" data-original-title="Edit">
                                 <span class="glyph-icon icon-edit button-content ">修改</span>
                             </a>
                             <a title="" data-id="{$item.id}" data-placement="top" class="btn small bg-white tooltip-button delete" href="javascript:void(0)" data-original-title="Remove">
                                 <span class="glyph-icon icon-remove "></span>删除
                             </a>    
                        </td>
                        </tr> 
                    </volist>
                    </tbody>
                </table>  
         
        </div>
          <div class="row">{$page}</div>
      </form>
         
    </div>
 
    <script type='text/javascript'>
       $('body').on('click','.delete', function(){
            var id = $(this).attr('data-id');
            var form = $("#articles-form");
            var ids_arr = new Array();
            $(".ids",form).each(function(){
                 if(this.checked){
                     ids_arr.push($(this).val())
                   }
             });  
            if(id){
                   var ids  = [id];     //单点
            }else{
                 var ids = ids_arr;   //批量
            }
            if(ids==''){
                layer.msg('请选择要删除的项');
                return false;
            }
            var delete_url = "{:U('Articles/delete')}";
            if (confirm("确定要删除!")){
            $.post(delete_url, {ids:ids}, function(data){
            if (data.status == 1){
                layer.msg(data.info);
                  window.location.reload();
                } else{
                   layer.msg(data.info);
                }
                }, 'json');
            } 
        });
        $(function(){
           $(".btnSearch").click(function(){
              var form = $("#articles-form");
               form.submit();
           });
        });
        
    </script>
 
</body>
</html>
