<?php include $this->admin_tpl('meta');?>
<title>添加配置 - YzmCMS内容管理系统</title>
</head>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			 <li><label><span class="c-red">*</span>配置名称：</label><input type="text" class="input" placeholder="必须为英文拼音或数字,如：qq" name="name" value=""></li>	
			 <li><label><span class="c-red">*</span>配置类型</label>
			 <span class="span_input" >
				<select name="fieldtype" class="select" style="width:230px" onchange="javascript:field_setting(this.value);">		
					<option value="textarea" selected>文本类型</option>					
					<option value="image">图片上传</option>
					<option value="attachment">附件上传</option>
					<option value="radio">radio选项卡</option>
					<option value="select">option下拉框</option>
				</select>
			 </span>
			 </li>	
			<li><label><span class="c-red">*</span>配置值：</label><span class="span_input" id="config_show"><textarea name="value" class="textarea w_420"  placeholder="例如：214243830"></textarea></span> </li>	
			 <li><label>简洁说明：</label><input type="text" class="input" style="width:488px" placeholder="例如：这个是站点QQ" name="title" value=""></li>
			 <li><label>状态</label>
			 <span class="span_input">
			 	<label class="label_radio"><input name="status" type="radio" value="1" checked> 启用</label>
			 	<label class="label_radio"><input name="status" type="radio" value="0"> 禁用</label>
			 </span>
			 </li>	
			 <li>&nbsp;<input type="hidden" name="dosubmit" value="1">
			 </li>			 
			<li>
			<input class="dosubmit w_120 btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			<input class="btn w_120 btn-default radius" type="button" value="取消" onclick="yzmcms_close()">
			</li>
		</ul>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer');?>

<script type="text/javascript">

	function field_setting(fieldtype) {
	    $.ajax({
            type: 'POST',
            url: '<?php echo U('public_gethtml');?>', 
            data: 'fieldtype='+fieldtype,
		    dataType: "html", 
            success: function (msg) {		
				$('#config_show').html(msg);
            }
        })		
	}


	function dosub(obj){
		 var reg = /^[A-Za-z0-9]+$/;
		 if($("input[name='name']").val()=='' || !reg.test($("input[name='name']").val())){
			 layer.msg('配置名称必须为英文拼音或数字！');
			 return false;
		 }

        $.ajax({
            type: 'POST',
            url: '<?php echo U('user_config_add');?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {		
				if(msg.status == 1){
					parent.location.reload();       
			    }else{
					layer.msg(msg.message);
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>