<!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">
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/date/datedropper.min.css">
    <script src="<?php echo base_url();?>public/js/date/datedropper.min.js"></script>
    <style type="text/css">
        .thumbnail {
            margin:10px;
        }

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

        .upimg {
            cursor: pointer;
        }
    </style>
    <style>
        .time{
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

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

</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12">
            <aside>
                <header><i class="fa fa-fw fa-file"></i>签到配置</header>
                <hr/>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <?php if($type== 2){ ?>
                                <div class="col-sm-5" style="border: 2px solid rgba(0,0,0,.075)">
                                <header><i class="fa fa-fw fa-file"></i>签到配置</header>
                                <ul class="nav nav-tabs">
                                	<?php foreach($section as $k => $v){ ?>
										<li role="presentation" class="<?php echo $k == 1 ? 'active' : ''; ?>">
											<a href="#<?php echo $k; ?>" aria-controls="<?php echo $k; ?>" role="tab" data-toggle="tab">
												<?php echo $v['start_level']."-".$v['end_level']; ?>
											</a>
										</li>
									<?php } ?>
								</ul>
								<div class="tab-content">
                                <?php foreach($daily as $dk => $dv){ ?>
                                	<div role="tabpanel" class="tab-pane <?php echo $dk == 1?'active':''; ?>" id="<?php echo $dk; ?>">
		                                <form class="form-horizontal J_ajaxForm" role="form" method="post" action="Config/actionSignInConfig/2" data-callBack="message" id="actionSginInConfig">
		                                	
		                                	<input type="hidden" class="time" name="section_id" value="<? echo $dk; ?>">
		                                	
		                                	<div class="modal-body" style="border: 2px solid rgba(0,0,0,.075)">
		                                		<div class="form-group">
	                                                <label class="col-sm-2 control-label">开始等级</label>
	                                                <div class="col-sm-10">
	                                                    <div class="col-sm-2">
	                                                        <input type="text" class="time" name="start_level" value="<? echo $section[$dk]['start_level']; ?>">
	                                                    </div>
	                                                </div>
	                                            </div>
		                                		<div class="form-group">
	                                                <label class="col-sm-2 control-label">结束等级</label>
	                                                <div class="col-sm-10">
	                                                    <div class="col-sm-2">
	                                                        <input type="text" class="time" name="end_level" value="<? echo $section[$dk]['end_level']; ?>">
	                                                    </div>
	                                                </div>
	                                            </div>
		                                	
		                                	</div>
		                                    <?php foreach ($dv as $x => $y) { ?>
		                                        <div class="modal-body" style="border: 2px solid rgba(0,0,0,.075)">
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">天数</label>
		                                                <div class="col-sm-10">
		                                                    <div class="col-sm-2">
		                                                        <input type="text" readonly class="time" value="<?php echo $y['id'];?>"/>
		                                                    </div>
		                                                </div>
		                                            </div>
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">金币</label>
		                                                <div class="col-sm-10">
		                                                    <div class="col-sm-3">
		                                                        <select class="form-control" name="coins[<?php echo $y['id'];?>]" style="display: inline-block;">
		                                                            <option value="coins01" <?php if($y['coins']['coins'] == 'coins01'){ echo 'selected';}?> >coins01</option>
		                                                            <option value="coins02" <?php if($y['coins']['coins'] == 'coins02'){ echo 'selected';}?> >coins02</option>
		                                                            <option value="coins03" <?php if($y['coins']['coins'] == 'coins03'){ echo 'selected';}?> >coins03</option>
		                                                            <option value="coins04" <?php if($y['coins']['coins'] == 'coins04'){ echo 'selected';}?> >coins04</option>
		                                                            <option value="coins05" <?php if($y['coins']['coins'] == 'coins05'){ echo 'selected';}?> >coins05</option>
		                                                            <option value="coins06" <?php if($y['coins']['coins'] == 'coins06'){ echo 'selected';}?> >coins06</option>
		                                                        </select>
		                                                    </div>
		                                                    <input type="text" class="time" name="bet[<?php echo $y['id'];?>]" value="<?php echo $y['coins']['bet'];?>" />
		                                                </div>
		                                            </div>
		
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">体力</label>
		                                                <div class="col-sm-10">
		                                                    <div class="col-sm-2">
		                                                        <input type="text" class="time" value="<?php echo $y['spins'];?>" name="spins[<?php echo $y['id'];?>]"/>
		                                                    </div>
		                                                </div>
		                                            </div>
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">道具奖励*: </label>
		                                                <div class="col-sm-10">
		                                                    <div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;">
		                                                        <?php foreach ($y['props'] as $k => $reward) { ?>
		                                                            <div class="form-group">
		                                                                <label class="col-sm-2 control-label">道具*: </label>
		                                                                <div class="col-sm-3">
		                                                                    <select class="form-control typeControl" name="props[<?php echo $y['id'];?>][propsId][]">
		                                                                        <?php foreach ($props as $pId => $p) { ?>
		                                                                            <option value="<?php echo $pId;?>" <?php if($reward['propsId'] == $pId) echo 'selected'; ?>><?php echo $p['msg'];?></option>
		                                                                        <?php } ?>
		                                                                    </select>
		                                                                </div>
		                                                                <label class="col-sm-2 control-label">数量*: </label>
		                                                                <div class="col-sm-3">
		                                                                    <input type="text" class="form-control"  name="props[<?php echo $y['id'];?>][num][]" value="<?php echo $reward['num'];?>">
		                                                                </div>
		                                                                <button type="button" class="btn btn-danger deleteParent" >删除</button>
		                                                            </div>
		                                                        <?php } ?>
		                                                        <button type="button" class="btn btn-success addParent" dayId="<?php echo $y['id'];?>" style="margin-left: 12px;margin-bottom: 10px;">增加</button>
		                                                    </div>
		                                                </div>
		                                            </div>
		                                        </div>
		                                    <?php } ?>
		                                    <div class="modal-footer">
		                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		                                        <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
		                                    </div>
		                                </form>
                                	</div>
                                <?php } ?>
                                
                                </div>
                            </div>
                            <?php }else{ ?>
                                <div class="col-sm-5" style="border: 2px solid rgba(0,0,0,.075)">
                                <header><i class="fa fa-fw fa-file"></i>签到进度配置</header>
                                <ul class="nav nav-tabs">
                                	<?php foreach($section as $k => $v){ ?>
										<li role="presentation" class="<?php echo $k == 1 ? 'active' : ''; ?>">
											<a href="#progress_<?php echo $k; ?>" aria-controls="progress_<?php echo $k; ?>" role="tab" data-toggle="tab">
												<?php echo $v['start_level']."-".$v['end_level']; ?>
											</a>
										</li>
									<?php } ?>
								</ul>
								
								<div class="tab-content">
                                <?php foreach($progress as $dk => $dv){ ?>
                                	<div role="tabpanel" class="tab-pane <?php echo $dk == 1?'active':''; ?>" id="progress_<?php echo $dk; ?>">
		                                <form class="form-horizontal J_ajaxForm" role="form" method="post" action="Config/actionSignInProgressConfig/2" data-callBack="message" id="actionSignInProgressConfig">
		                                	
		                                	<input type="hidden" class="time" name="section_id" value="<? echo $dk; ?>">
		                                	
		                                    <?php foreach ($dv as $x => $y) { ?>
		                                        <div class="modal-body" style="border: 2px solid rgba(0,0,0,.075)">
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">进度</label>
		                                                <div class="col-sm-10">
		                                                    <div class="col-sm-2">
		                                                        <input type="text" readonly class="time" value="<?php echo $y['progress'];?>"/>
		                                                    </div>
		                                                </div>
		                                            </div>
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">金币</label>
		                                                <div class="col-sm-10">
		                                                    <div class="col-sm-3">
		                                                        <select class="form-control" name="coins[<?php echo $y['progress'];?>]" style="display: inline-block;">
		                                                            <option value="coins01" <?php if($y['coins']['coins'] == 'coins01'){ echo 'selected';}?> >coins01</option>
		                                                            <option value="coins02" <?php if($y['coins']['coins'] == 'coins02'){ echo 'selected';}?> >coins02</option>
		                                                            <option value="coins03" <?php if($y['coins']['coins'] == 'coins03'){ echo 'selected';}?> >coins03</option>
		                                                            <option value="coins04" <?php if($y['coins']['coins'] == 'coins04'){ echo 'selected';}?> >coins04</option>
		                                                            <option value="coins05" <?php if($y['coins']['coins'] == 'coins05'){ echo 'selected';}?> >coins05</option>
		                                                            <option value="coins06" <?php if($y['coins']['coins'] == 'coins06'){ echo 'selected';}?> >coins06</option>
		                                                        </select>
		                                                    </div>
		                                                    <input type="text" class="time" name="bet[<?php echo $y['progress'];?>]" value="<?php echo $y['coins']['bet'];?>" />
		                                                </div>
		                                            </div>
		
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">体力</label>
		                                                <div class="col-sm-10">
		                                                    <div class="col-sm-2">
		                                                        <input type="text" class="time" value="<?php echo $y['spins'];?>" name="spins[<?php echo $y['progress'];?>]"/>
		                                                    </div>
		                                                </div>
		                                            </div>
		                                            <div class="form-group">
		                                                <label class="col-sm-2 control-label">道具奖励*: </label>
		                                                <div class="col-sm-10">
		                                                    <div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;">
		                                                        <?php foreach ($y['props'] as $k => $reward) { ?>
		                                                            <div class="form-group">
		                                                                <label class="col-sm-2 control-label">道具*: </label>
		                                                                <div class="col-sm-3">
		                                                                    <select class="form-control typeControl" name="props[<?php echo $y['progress'];?>][propsId][]">
		                                                                        <?php foreach ($props as $pId => $p) { ?>
		                                                                            <option value="<?php echo $pId;?>" <?php if($reward['propsId'] == $pId) echo 'selected'; ?>><?php echo $p['msg'];?></option>
		                                                                        <?php } ?>
		                                                                    </select>
		                                                                </div>
		                                                                <label class="col-sm-2 control-label">数量*: </label>
		                                                                <div class="col-sm-3">
		                                                                    <input type="text" class="form-control"  name="props[<?php echo $y['progress'];?>][num][]" value="<?php echo $reward['num'];?>">
		                                                                </div>
		                                                                <button type="button" class="btn btn-danger deleteParent" >删除</button>
		                                                            </div>
		                                                        <?php } ?>
		                                                        <button type="button" class="btn btn-success addParent" dayId="<?php echo $y['progress'];?>" style="margin-left: 12px;margin-bottom: 10px;">增加</button>
		                                                    </div>
		                                                </div>
		                                            </div>
		                                        </div>
		                                    <?php } ?>
		                                    <div class="modal-footer">
		                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		                                        <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
		                                    </div>
		                                </form>
		                             </div>
		                         <?php } ?>
                                
                                </div>
                            </div>
                            <?php } ?>
                        </div>
                    </div>
                </section>
            </aside>
        </div>
    </div>
</div>

</body>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script src="<?php echo base_url();?>public/js/common.js"></script>
<script>

    var idData = JSON.parse('<?php echo json_encode($props); ?>');
    function message(returnData, $from) {
        window.location.reload();
    }

    $('.addOrDelControl').on("click",'.deleteParent',function(){
        $(this).parent().remove();
    });

    $('.addParent').on("click",function(){
        var id  = $(this).attr("dayId");
        var str = '';
        str += '<div class="form-group"><label class="col-sm-2 control-label">道具*: </label><div class="col-sm-3"><select class="form-control typeControl" name="props['+id+'][propsId][]">';
        for(var x in idData) {
            str += '<option value="'+x+'">'+idData[x]['msg']+'</option>';
        }
        str += '</select></div><label class="col-sm-2 control-label">数量*: </label><div class="col-sm-3"><input type="text" class="form-control" name="props['+id+'][num][]" value="1"></div><button type="button" class="btn btn-danger deleteParent" >删除</button></div>';
        $(this).before(str);
    });
</script>
</html>