<?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-content">
                <div class="row">
                    <div class="col-sm-12">
                        <form role="form" class="form-horizontal data-from" id="theFrm">
                            <input type="hidden" name="id" value="<?=intval($info->id)?>">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">编号</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->code?></p>
                                </div>
                                <label class="col-sm-2 control-label">车牌号</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->car_no?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">车架号</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->order->car_frame_no?></p>
                                </div>
                                <label class="col-sm-2 control-label">发动机号</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->order->engine_no?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商业保单号</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->order->insurer1_no?></p>
                                </div>
                                <label class="col-sm-2 control-label">有效期时间</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->end_date?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">共使用数</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->typeNew->use_num?></p>
                                </div>
                                <label class="col-sm-2 control-label">剩余使用次数</label>
                                <div class="col-sm-4">
                                    <p class="form-control-static"><?=$info->typeNew->use_num - $info->finished_num?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-8">
                                    <textarea name="remark" class="form-control"></textarea>
                                </div>
                            </div>
                            <?php if($info->typeNew->use_num > $info->finished_num) {?>
                                <div>
                                    <div class="row">
                                        <div class="col-sm-5 col-sm-offset-5">
                                            <button class="btn btn-primary btn-save" type="button">
                                                <strong>提 交</strong>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            <?php } ?>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>操作记录</h5>
            </div>
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-12">
                        <table id="listTable">
                            <thead>
                            <tr>
                                <th data-field="id">序号</th>
                                <th data-field="op_man">操作者</th>
                                <th data-field="op_time">操作时间</th>
                                <th data-field="info">操作内容</th>
                                <th data-field="remark">备注</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 type="text/javascript" language="javascript">
        function search() {
            $('#listTable').bootstrapTable('destroy');
            $('#listTable').bootstrapTable({
                url: "/gift/history-log-json",
                pagination: true,
                sidePagination: 'server',
                queryParams: function(params) {
                    params.id = <?=$info->id?>;
                    return params;
                }
            });
            return false;
        }
        $(function () {
            search();
            //提交按钮
            $(".btn-save").click(function(){
                parent.layer.confirm('是否确认提交？', {
                    btn: ['确认','取消'], //按钮
                    shade: false //不显示遮罩
                }, function(){
                    var params = $("#theFrm").serialize();
                    params += '&status=2';
                    $.post('/gift/use-save',params,function(obj){
                        parent.layer.msg(obj.msg);
                        if(obj.success) {
                            parent.refreshList();
                            layer_close();
                        }
                    },'json');
                }, function(){
                    //
                });
            });
        })
    </script>
<?php $this->endBlock('footer_js'); ?>