<?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>工号</label>
                    <input type="text" name="username" id="username" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label>真实姓名</label>
                    <input type="text" name="name" id="name" class="form-control">
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label>工资月份</label>
                    <input type="text" name="pay_date" id="pay_date" class="form-control date" value="<?=date('Y-m')?>" autocomplete="off">
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label>是否离职</label>
                    <select name="is_leave" class="form-control">
                        <option value="">全部</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
                <div class="form-group" style="margin-bottom: 8px;margin-left:20px;">
                    <label>分组</label>
                    <select name="group_id" class="form-control">
                        <option value="0">全部</option>
                        <?php
                        foreach($group_items as $group) {
                            echo '<option value="'.$group->id.'">'.$group->name.'</option>';
                        }
                        ?>
                    </select>
                </div>
                <div class="form-group" style="margin-bottom: 8px;">
                    <label>状态</label>
                    <select name="status_id" class="form-control">
                        <option value="0">全部</option>
                        <option value="1">人事✔</option>
                        <option value="2">出纳✔</option>
                        <option value="3">人事✔,出纳✔</option>
                        <option value="4">财务✔</option>
                        <option value="5">老板✔</option>
                        <option value="6">已发放</option>
                        <option value="7">退回</option>

                    </select>
                </div>
                <button type="submit" class="btn btn-primary mb-8">搜索</button>
            </form>
            <div class="row" style="margin-top:20px;">
                <div class="col-md-12">
                    <table id="listTable">
                        <thead class="bg-warning">
                        <tr>
                            <th width="50" data-field="id">ID</th>
                            <th data-field="username">工号</th>
                            <th data-field="name">真实姓名</th>
                            <th data-field="pay_date">工资月份</th>
                            <th data-field="group_name">所属岗位</th>
                            <th data-field="real_pay">基本工资</th>
                            <th data-field="should_pay">提成工资</th>
                            <th data-field="is_leave">是否离职</th>
                            <th data-field="status_name">状态</th>
                            <th data-formatter="opFormatter">操作</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 opFormatter(value, row, index) {
        var opStr = [];
        if(row.is_show == 1) {
            opStr.push('<a href="javascript:void(0);" onclick="edit(' + row.id + ')">');
            opStr.push('<i class="fa fa-edit" title="详情"></i>');
            opStr.push('</a>');
        }

        return opStr.join(' ');
    }
    function edit(id) {
        var title = '详情';
        var pay_date = $('#pay_date').val();
        layer_show(title, '/finance/gongzi-all-info?id=' + id + '&pay_date=' + pay_date);
    }
    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: "/finance/pay2-list-json",
            pagination: false,
            sidePagination: 'server',
            queryParams: function(params) {
                o['offset'] = params['offset'];
                o['limit'] = params['limit'];
                return o;
            }
        });
        return false;
    }

    $(function() {
        search();

        $('.date').datepicker({
            minViewMode: 1,
            keyboardNavigation: false,
            forceParse: false,
            autoclose: true,
            todayHighlight: true,
            format: "yyyy-mm"
        });
    });
</script>
<?php $this->endBlock(); ?>