<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/iCheck/custom.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-1 control-label">车牌号</label>
                            <div class="col-sm-3">
                                <input type="text" name="car_no" value="<?=$info->car_no?>" class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">车架号</label>
                            <div class="col-sm-3">
                                <input type="text" name="car_frame_no" value="<?=$info->car_frame_no?>" class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">发动机号</label>
                            <div class="col-sm-3">
                                <input type="text" name="engine_no" value="<?=$info->engine_no?>" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">车主</label>
                            <div class="col-sm-3">
                                <input type="text" name="car_man" value="<?=$info->car_man?>" class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">证件类型</label>
                            <div class="col-sm-3">
                                <select name="car_man_type" class="form-control">
                                    <option value="身份证">身份证</option>
                                    <option value="营业执照">营业执照</option>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label">证件号码</label>
                            <div class="col-sm-3">
                                <input type="text" name="car_man_number" value="<?=$info->car_man_number?>" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">联系电话</label>
                            <div class="col-sm-3">
                                <input type="text" name="car_man_phone" value="<?=$info->car_man_phone?>" class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">厂牌型号</label>
                            <div class="col-sm-3">
                                <input type="text" name="factory_model" value="<?=$info->factory_model?>" class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">初登日期</label>
                            <div class="col-sm-3">
                                <input type="text" name="register_date" value="<?=$info->register_date?>" class="form-control date" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">座位数</label>
                            <div class="col-sm-3">
                                <input type="text" name="seats" value="<?=$info->seats?>" class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">使用性质</label>
                            <div class="col-sm-3">
                                <select name="car_use_id" class="form-control">
                                    <option value="0">---请选择---</option>
                                    <?php
                                    foreach($car_use_items as $item) {
                                        echo '<option value="'.$item->id.'"';
                                        if($info->car_use_id == $item->id)
                                            echo ' selected ';
                                        echo '>'.$item->name.'</option>';
                                    }
                                    ?>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label">购置价</label>
                            <div class="col-sm-3">
                                <input type="text" name="purchase_price" value="<?=$info->purchase_price?>" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">备注</label>
                            <div class="col-sm-11">
                                <textarea name="remark" class="form-control"><?=$info->remark?></textarea>
                            </div>
                        </div>
                        <div>
                            <div class="row">
                                <div class="col-sm-5 col-sm-offset-5">
                                    <button class="btn btn-primary btn-save" type="button">
                                        <strong><?=$info ? '保 存':'添 加'?></strong>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->beginBlock('footer_js'); ?>
<script type="text/javascript" language="javascript">
    $(function () {
        $('.date').datepicker({
            todayBtn: "linked",
            keyboardNavigation: false,
            forceParse: false,
            calendarWeeks: true,
            autoclose: true
        });
        //提交按钮
        $(".btn-save").click(function(){
            parent.layer.confirm('是否确认提交？', {
                btn: ['确认','取消'], //按钮
                shade: false //不显示遮罩
            }, function(){
                var params = $("#theFrm").serialize();
                $.post('/car/save',params,function(obj){
                    if(obj.success) {
                        parent.layer.msg('保存成功');
                        parent.refreshList();
                        layer_close();
                    } else {
                        parent.layer.msg(data.msg);
                    }
                },'json');
            }, function(){
                //
            });
        });
    })
</script>
<?php $this->endBlock('footer_js'); ?>
