@extends('admin/layout')
@section('content')
    <body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        收款金额=合同总金额:<span id="sum_total">{{$sum_total??0}}</span>
                    </div>
                    <div class="ibox-content">
                        <form class="form-inline" id="searchForm" onsubmit="units.search();return false;">

                            <div class="form-group" style="margin-top: 5px;">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入域名或项目名称" class="input-md form-control"
                                           name="keyword"
                                           id="keyword">
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-md btn-primary"
                                                onclick="units.search()"> 搜索</button>
                                        <button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px"
                                                name="resetBtn"> 重置</button>
                                    </span>
                                </div>
                            </div>
                        </form>
                        <hr>

                        <div class="table-responsive">

                            <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>

                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
    </body>
@endsection
@section('footer')
    <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
    <script>

        var units = {
            getIdsBySelections: function () {
                var selections = $("#table").bootstrapTable('getSelections');
                var ids = [];
                $.each(selections, function (inx, val) {
                    ids.push(val.id);
                });
                return ids;
            },

            save: function (id,type_status) {
                layer.open({
                    type: 2,
                    content: ['/admin/finance/' + id + '/save'],
                    area: ['90%', '80%'],
                    title: '信息详情'
                });
            },
            search: function () {
                tips.selectPage();
            },
        };

        var config = {};
        config.url = '/admin/finances/finances_collection';
        config.columns = [ //字段
            {
                title: '序号', align: 'center', formatter: function (value, item, index) {
                    return index + 1;
                }
            },

            {title: '项目ID', field: 'id', align: 'center'},
            {title: '项目名称', field: 'cn_title', align: 'center'},
            {title: '合同总金额', field: 'contract_total_fee', align: 'center'},
            {title: '维基百科费用', field: 'wiki_fee', align: 'center'},
            {title: '其他费用', field: 'other_fee', align: 'center'},
            {title: '项目状态', field: 'status_title', align: 'center'},
            {title: '创建时间', field: 'created_at', align: 'center'},
            {
                title: '操作', field: 'id', align: 'center',
                formatter: function (value, row) {
                    var str = '';
                    // if (row.status === 1) {
                    str += '<button onclick="units.save(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>查看详情</button>';
                    // }
                    return str;
                }

            },

        ];
        tips.bootstrapTable(config);
        config.onLoadSuccess = function (data) {
             $("#sum_total").text(data.sum_total);
        };
        laydate.render({
            elem: '#start_at', //指定元素
            type: 'datetime'
        });
        laydate.render({
            elem: '#end_at', //指定元素
            type: 'datetime'
        });
    </script>
@endsection