<?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-5">
                                <input type="text" name="name" value="<?=$info->name?>" class="form-control">
                            </div>
                            <label class="col-sm-1 control-label">上级</label>
                            <div class="col-sm-5">
                                <select name="parent_id" class="form-control">
                                    <option value="0">--无上级---</option>
                                    <?php
                                    foreach($parent_items as $item) {
                                        echo '<option value="'.$item['id'].'"';
                                        if($item['id'] == $info->parent_id)
                                            echo ' selected ';
                                        echo '>';
                                        echo $item['name'];
                                        echo '</option>';
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">区别</label>
                            <div class="col-sm-5">
                                <select name="difc" class="form-control">
                                    <option value="0"></option>
                                    <option value="1" <?=$info->difc==1?'selected':''?>>新保</option>
                                    <option value="2" <?=$info->difc==2?'selected':''?>>续保</option>
                                    <option value="3" <?=$info->difc==3?'selected':''?>>增加新保</option>
                                    <option value="4" <?=$info->difc==4?'selected':''?>>增加清洗库</option>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label">排序</label>
                            <div class="col-sm-5">
                                <input type="text" name="paixu_id" value="<?=$info->paixu_id?>" class="form-control">
                            </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" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript">
    $(function () {
        //提交按钮
        $(".btn-save").click(function(){
            parent.layer.confirm('是否确认提交？', {
                btn: ['确认','取消'], //按钮
                shade: false //不显示遮罩
            }, function(){
                var params = $("#theFrm").serialize();
                $.post('/invalid/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'); ?>
