<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>宠物配置</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/bootstrap/bootstrap.min.css" >
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>public/css/jquery.timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.min.css">

    <style type="text/css">
        .thumbnail {
            margin:10px;
        }

        .lang-name {
            margin-left:42px;
        }

        .upimg {
            cursor: pointer;
        }

    </style>
</head>
<body>
<div id="msg-tip">

</div>
<div class="content_wrapper">
    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="goodForm" action="#" style="margin-top: 20px">
                <input type="hidden" value="petConfig" name="type"/>
                <header><i class="fa fa-fw fa-file"></i>宠物配置</header>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-success" id="goodsubmitBtn">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid">
                        <?php foreach ($petConfig as $key => $vl) { ?>
                            <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                                <div class="form-group" >
                                    <label class="col-sm-1 control-label">宠物ID</label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" readonly name="pet[<?php echo $vl['id'];?>][petId]" value="<?php echo $vl['id'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">宠物名称</label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="pet[<?php echo $vl['id'];?>][form]" value="<?php echo $vl['form'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">喂养激活时间</label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="pet[<?php echo $vl['id'];?>][activateTime]" value="<?php echo $vl['activateTime'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">孵化类型</label>
                                    <div class="col-sm-1">
                                        <select class="form-control" name="pet[<?php echo $vl['id'];?>][incubateType]">
                                            <option value="0" <?php if($vl['incubateType'] == 0) echo 'selected'; ?>>等級</option>
                                            <option value="2" <?php if($vl['incubateType'] == 2) echo 'selected'; ?>>卡组</option>
                                        </select>
                                    </div>
                                    <label class="col-sm-1 control-label">孵化数值</label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="pet[<?php echo $vl['id'];?>][incubateFrom]" value="<?php echo $vl['incubateFrom'];?>">
                                    </div>
                                    <div class="col-sm-1">
                                        <a href="/#pet/config/<?php echo $vl['id'];?>" class="btn btn-primary active" role="button">技能&经验</a>
                                    </div>
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                </section>
            </form>
        </aside>
    </div>
</div>
</body>

<script>
    $(function () {
        $('#goodsubmitBtn').click(function () {
            var data = new FormData(document.getElementById("goodForm"));
            $.ajax({
                url: rootPath + 'pet/actionConfig',
                type: 'POST',
                data: data,
                dataType: 'json',
                contentType: false, //必须
                processData: false, //必须
                success: function (data) {
                    alert(data.msg);
                    window.location.reload();
                },
                error: function (msg) {
                    alert(data.msg);
                }
            });
        });
    });
</script>
</html>
