<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<?php $this->endBlock(); ?>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>礼品统计</h5>
            <div class="ibox-tools">
                <a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');">
                    <i class="fa fa-refresh"></i> 刷新
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form role="form" id="searchFrm" class="form-inline" onsubmit="return search();">
                <div class="form-group" style="margin-bottom: 8px;">
                    <label for="date_type">范围</label>
                    <select id="date_type" name="date_type" class="form-control">
                        <option value="0">全部</option>
                        <option value="1">出库时间</option>
                        <option value="2">正本生成时间</option>
                        <option value="3">提单时间</option>
                    </select>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <div class="input-daterange input-group" id="datepicker">
                        <input type="text" class="input-sm form-control" id="begin_date" name="begin_date" autocomplete="off" value="" />
                        <span class="input-group-addon">到</span>
                        <input type="text" class="input-sm form-control" id="end_date" name="end_date" autocomplete="off" value="" />
                    </div>
                </div>
                <button type="submit" class="btn btn-primary mb-8">搜索</button>
            </form>
            <div class="row">
                <div class="col-sm-12">
                    <table id="listTable">
                        <thead>
                        <tr>
                            <th width="50" data-field="id">ID</th>
                            <th data-field="name">名称</th>
                            <th data-field="unout_total">待出库</th>
                            <th data-field="out_total">已出库</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<?php $this->beginBlock('footer_js'); ?>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
    var o = {};
    function refreshList() {
        $('#listTable').bootstrapTable('refresh');
    }

    function search() {
        o = {};
        var params = $("#searchFrm").serializeArray();
        $.each(params, function(index) {
            o[this['name']] = this['value'];
        });
        $('#listTable').bootstrapTable('destroy');
        $('#listTable').bootstrapTable({
            url: "/gift/gift-tj-json",
            pagination: true,
            sidePagination: 'server',
            queryParams: function(params) {
                o['offset'] = params['offset'];
                o['limit'] = params['limit'];
                return o;
            }
        });
        return false;
    }

    $(function() {
        $('.input-daterange').datepicker({
            keyboardNavigation: false,
            forceParse: false,
            autoclose: true
        });
        search();
    });
</script>
<?php $this->endBlock(); ?>