<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css">
<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>流水账列表<?php echo $rid;?></header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                            	<div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="" name="stanpform"  style="margin-bottom:20px;">
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>时间</label>
                                            <input type="text" class="form-control datetimepicker" value="<?php if($date) echo $date;?>" placeholder="时间" name="date" />
                                            <select name="rid" class="form-control">
                                                <option value="0">所有</option>
                                                <option value="217" <?php if($rid == 217) echo 'selected'; ?>>通行证</option>
                                                <option value="112" <?php if($rid == 112) echo 'selected'; ?>>宠物升级</option>
                                            </select>
                                        </div>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                        <a class="btn btn-primary" href="#user/manyDaysLog/<?php echo $uid;?>">多日期查询</a>
                                    </form>
                                </div>
                                
                                <div class="col-sm-12">
                                    <div class="btn-group" style="margin-bottom:20px;">
                                        <a href="#user/log/<?php echo $uid;?>/all" class="btn btn-success">所有</a>
                                        <?php foreach ($typeMap as $typeText => $item){ ?>
                                            <a href="#user/log/<?php echo $uid;?>/<?=$typeText?>" class="btn btn-success"><?=$item['text']?></a>
                                        <?php }?>
<!--                                        <a href="#user/log/--><?php //echo $uid;?><!--/spins" class="btn btn-success">体力</a>-->
<!--                                        <a href="#user/log/--><?php //echo $uid;?><!--/shield" class="btn btn-success">盾牌</a>-->
<!--                                        <a href="#user/log/--><?php //echo $uid;?><!--/star" class="btn btn-success">星星</a>-->
<!--                                        <a href="#user/log/--><?php //echo $uid;?><!--/props" class="btn btn-success">道具</a>-->
<!--                                        <a href="#user/log/--><?php //echo $uid;?><!--/card" class="btn btn-success">卡片</a>-->
<!--                                        <a href="#user/log/--><?php //echo $uid;?><!--/diamond" class="btn btn-success">钻石</a>-->
                                    </div>

                                    
                                    <div class="form-group" style="margin-bottom:20px;float: right">
                                    	
                                        <div>
                                            <label>金币：</label>
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="+ <?php echo $moneyadd ?? 0;?>">
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="- <?php echo $moneylow ?? 0;?>">
                                            <label>体力：</label>
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="+ <?php echo $spinsadd ?? 0;?>">
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="- <?php echo $spinslow ?? 0;?>">
                                        </div>
                                        <div>
                                            <label>盾牌：</label>
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="+ <?php echo $shieldadd ?? 0;?>">
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="- <?php echo $shieldlow ?? 0;?>">
                                            <label>星星：</label>
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="+ <?php echo $staradd ?? 0;?>">
                                            <input type="text" class="form-control" style="display: inline-block;width: 10em;" readonly value="- <?php echo $starlow ?? 0;?>">
                                        </div>
                                        
                                        <div>
                                            <a type="button" class="btn btn-primary" href="/Export/userlog/<?=$uid;?>/<?=date('Ymd', strtotime($date))?>" style="margin-top:20px;float: right;">导出流水</a>
                                    	</div>
                                    </div>

                                    <div class="btn-group" style="margin-bottom:20px;display: table">
                                        <button class="btn btn-primary" onclick="actionCrease(0)">默认</button>
                                        <button class="btn btn-success" onclick="actionCrease(1)">增</button>
                                        <button class="btn btn-danger"  onclick="actionCrease(2)">减</button>
                                    </div>
									
									<div class="btn-group" style="margin-bottom:20px;display: table">
                                        <button class="btn btn-primary" onclick="actionSort('')">默认排序</button>
                                        <button class="btn btn-success" onclick="actionSort('DESC')">由大到小</button>
                                        <button class="btn btn-danger"  onclick="actionSort('ASC')">由小到大</button>
                                    </div>
                                    
                                    
                                    

                                    <div class="table-responsive">
                                        <table id="exchangeTable" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>类型</th>
                                                <th>rid</th>
                                                <th>数量</th>
                                                <th>增减</th>
                                                <th>来源</th>
                                                <th>最终值</th>
                                                <th>时间</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>

<script src="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script type="text/javascript">
    $(function () {
        //查询
        //jquery data table 初始化
        var exchangeTable = $("#exchangeTable").DataTable({
            "paging": true,
            "select": true,
            "processing": true,
            "serverSide": true,
            "language": {
                'lengthMenu': '每页显示 _MENU_ 记录',
                'zeroRecords': '没有数据',
                'info': ' 第_PAGE_ 页/ _PAGES_页，共 _TOTAL_ 条',
                'infoEmpty': '没有符合条件的记录',
                'search': '查找',
                'infoFiltered': '(从  _MAX_ 条记录中过滤)',
                'paginate': { "first":  "首页 ", "last": "末页", "next": "下一页","previous": "上一页"}

            },
            "ajax": {
                url: rootPath + "user/getlog?uid=<?php echo $uid;?><?php echo '&type='.$type;?><?php echo '&crease='.$crease;?><?php echo '&sort='.$sort;?><?php echo '&rid='.$rid;?>",
                type:"post",
                //增加参数查询参数
                data:function(data){
					data.date = '<?php echo strtotime($date); ?>';
					console.log(data);
                }
            },
            "lengthChange": true,
            "searching": false,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            "columns": [
                {"data": "type"},
                {"data": "rid"},
                {"data": "num"},
                {"data": "crease"},
                {"data": "reason"},
                {"data": "last_num"},
                {"data": "time"},
            ]
        });

        //当点击search按钮时按条件重新加载数据
        $("#searchBtn").click(function(){
            if($("#exchangeForm").valid()) {
                exchangeTable.ajax.reload();
            }
        });
    });

    function actionCrease(type) {
        window.location.href = "/#user/log/<?php echo $uid;?><?php echo '/'.$type;?>/"+type
    }
    
    function actionSort(type) {
        window.location.href = "/#user/log/<?php echo $uid;?><?php echo '/'.$type;?>/<?php echo '/'.$crease;?>/"+type
    }

</script>

<script>
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
</script>
