<?php
use yii\web\View;

$this->title = '我的客户';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?=$this->title?></title>
    <link href="/js/lib/datepicker/css/bootstrap.css" rel="stylesheet">
    <link href="/js/lib/datepicker/css/bootstrap-datepicker.css" rel="stylesheet">
    <link href="/css/base.css" rel="stylesheet">
    <link href="/css/pages/edit.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div id="inner-hd">
        <div class="crumbs">
            <i class="crumbs-arrow"></i>
            <a href="javascript:;" class="crumbs-label"><?=$this->title?></a>
        </div>
    </div>
    <div id="inner-bd">
        <div class="button-group">
            <div class="button current save-btn">
                <i class="iconfont">&#xe76a;</i>
                <span class="button-label">保存</span>
            </div>
            <div class="button back-btn">
                <i class="iconfont">&#xe600;</i>
                <span class="button-label">返回</span>
            </div>
        </div>
        <form id="theFrm" method="post" action="/sales-mng/my-cars-save">
            <input type="hidden" name="id" value="<?=$info->id?>">
            <input name="_csrf" type="hidden" id="_csrf" value="<?=Yii::$app->request->csrfToken ?>">
            <table class="kv-table">
                <tbody>
                <tr>
                    <td class="kv-label">车牌号</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="car_no" name="car_no" value="<?=$info->car_no?>">
                    </td>
                    <td class="kv-label">厂牌型号</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="factory_model" name="factory_model" value="<?=$info->factory_model?>">
                    </td>
                    <td class="kv-label">车型</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="car_model" name="car_model" value="<?=$info->car_model?>">
                    </td>
                </tr>
                <tr>
                    <td class="kv-label">发动机号</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="engine_no" name="engine_no" value="<?=$info->engine_no?>">
                    </td>
                    <td class="kv-label">车架号</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="car_frame_no" name="car_frame_no" value="<?=$info->car_frame_no?>">
                    </td>
                    <td class="kv-label">初登日期</td>
                    <td class="kv-content">
                        <div class="date">
                            <input style="width:80%;" type="text" id="register_date" name="register_date" value="<?=$info->register_date?>">
                            <i class="iconfont">&#xe784;</i>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="kv-label">车辆类型</td>
                    <td class="kv-content">
                        <select id="car_type_id" name="car_type_id">
                            <option value="0">---请选择---</option>
                            <?php
                            foreach($car_type_items as $item) {
                                echo '<option value="'.$item->id.'"';
                                if($info->car_type_id == $item->id)
                                    echo ' selected ';
                                echo '>'.$item->name.'</option>';
                            }
                            ?>
                        </select>
                    </td>
                    <td class="kv-label">运营性质</td>
                    <td class="kv-content">
                        <select name="car_use_id" id="car_use_id">
                            <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>
                    </td>
                    <td class="kv-label">座位数</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="seats" name="seats" value="<?=$info->seats?>">
                    </td>
                </tr>
                <tr>
                    <td class="kv-label">品牌</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="brand" name="brand" value="<?=$info->brand?>">
                    </td>
                    <td class="kv-label">年份</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="car_year" name="car_year" value="<?=$info->car_year?>">
                    </td>
                    <td class="kv-label">排量</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="displacement" name="displacement" value="<?=$info->displacement?>">
                    </td>
                </tr>
                <tr>
                    <td class="kv-label">车主</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="car_man" name="car_man" value="<?=$info->car_man?>">
                    </td>
                    <td class="kv-label">联系电话</td>
                    <td class="kv-content">
                        <input style="width:85%;" type="text" id="phone" name="phone" value="<?=$info->phone?>">
                    </td>
                    <td class="kv-label"></td>
                    <td class="kv-content"></td>
                </tr>
                <tr>
                    <td class="kv-label">备注</td>
                    <td colspan="5" class="kv-content">
                        <textarea style="width:97%; height: 50px;" name="remark" id="remark"><?=$info->remark?></textarea>
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>

    <div id="inner-ft">

    </div>
</div>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/global.js"></script>
<script type="text/javascript" src="/js/jquery.select.js"></script>
<script type="text/javascript" src="/js/jquery.pagination.js"></script>
<script type="text/javascript" src="/js/lib/layer/layer.js"></script>
<script type="text/javascript" src="/js/common.js"></script>

<script type="text/javascript" src="/js/lib/datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="/js/lib/datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script type="text/javascript">
    $(function(){
        $('select').select();
        $('.save-btn').click(function(){
            var params = $('#theFrm').serialize();
            var url = $('#theFrm').attr('action');
            $.post(url,params,function(obj){
                if(obj.success) {
                    alert(obj.msg);
                    window.location.href =  '/sales-mng/my-cars';
                } else {
                    alert(obj.msg);
                }
            },'json');
        });
        $('.back-btn').click(function(){
            window.history.go(-1);
        });
        $("#register_date").datepicker({
            "language":"zh-CN",
            "format": 'yyyy-mm-dd'
        })
        $(".date .iconfont").click(function(){
            $(this).prev().trigger("focus");
        });
    });
</script>
</body>
</html>
