<{include file="./admin/header.html"}>
<{include file="./admin/left.html"}>
<{include file="./admin/nav.html"}>
<{include file="get_kindeditor.html"}>
<style>
.set-nav {
	margin: 0 auto;
}
.set-nav-hr {
	background-color: #ddd;
    height: 1px;
    position: relative;
}
.form-group label {
	font-weight: 600;
}
.checkbox-inline, .radio-inline {
	font-weight: 400!important;
}
.rowlabel {
	font-weight: 300!important;
}
.music_play_hide {
	display:none;
}
</style>


<div id="activity_container">

<form id="activity_form">
<div class="activity_center">
<{include file="./admin/activity/common_nav.html"}>

	<input name="events_id" type="hidden" value="<{$events_Data.events.id}>">
	
	<div  class="panel panel-default">
	<div class="panel-heading"><h3 class="panel-title" id="panel-title">表单设置</h3></div>
	<div class="panel-body">
		<table class="table">
				<thead>
				<tr>
					<th>名称</th>
					<th>类型</th>
					<th>是否必填</th>
				</tr>
				<{foreach from=$events_Data.events.forms item=form}>
				<tr>
					<td><{$form.name}></td>
					<td><{if $form.type== 'text'}>单行文本<{/if}>
					<{if $form.type== 'textarea'}>多行文本<{/if}>
					<{if $form.type== 'select'}>下拉菜单<{/if}></td>
					<td><{if $form.required==1}>必填<{else}> 选填<{/if}></td>
				</tr>
				<{/foreach}>
				</thead>
		</table>
		</div>
		<div  style="text-align:right; margin-right: 20px;margin-bottom: 10px;"><a href="?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>&typ=input">点击编辑</a></div>
	</div>
	
	<div  class="panel panel-default">
	<div class="panel-heading"><h3 class="panel-title" id="panel-title">奖品设置</h3></div>
	<div class="panel-body">
		<table class="table">
				<thead>
				<tr>
					<th>序号</th>
					<th>奖品名称</th>
					<th>图片</th>
					<th>数量</th>
					<th>操作</th>
				</tr>
				<{foreach from=$events_Data.events.survery_prize key=index  item=survery_prize name=survery}>
					<tr>
					<td><{$smarty.foreach.survery.iteration}></td>
					<td><{$survery_prize.name}></td>
					<td><img src="<{$survery_prize.img_url}>" class="img-thumbnail" style="width:50px;"></td>
					<td><{$survery_prize.num}><{$survery_prize.unit_name}></td>
					<td><a class="del_survery_prize" survery_prize_id='<{$index}>'  href="javascript:;">删除</a></td>
					</tr>
				<{/foreach}>
				</thead>
		</table>
	</div>
		<div  style="text-align:right; margin-right: 20px;margin-bottom: 10px;"><a href="?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>&typ=prize"><i class="fa fa-plus"></i>添加奖品</a></div>
	</div>
	
	
	
	<div  class="panel panel-default">
	<div class="panel-heading"><h3 class="panel-title" id="panel-title">问题设置</h3></div>
		<div class="panel-body">
			<div class="form-group">
				<{foreach from=$events_Data.events.survery_question key=index  item=survery_question}>
				
				<{if $survery_question.type=='img'}>
						<div class="panel panel-default" style="padding: 10px;">
						<{*<div style="margin: 10px;" >排序:  &nbsp; &nbsp; &nbsp; <{$index}></div>*}>
						<div style="margin: 10px;">问题:   &nbsp; &nbsp; &nbsp; <{$survery_question.question}></div>
						<div style="margin: 10px;">类型:  &nbsp; &nbsp; &nbsp; 图片</div>
							<div style="clear:both;"></div>
							<table class="table">
								<tr>
										<{foreach from=$survery_question.answer key=key  item=answer}>
										<td style="text-align:center;">
											<img id="img_url_tag" src="<{$answer.img_url}>" style="width:100px;" class="img-thumbnail"><br>
											<div style="text-align:center;">选择:<{$answer.answer}></div>
										</td>
										<{/foreach}>
										
								</tr>
							</table>
							<div style="margin: 10px;">操作:  &nbsp; &nbsp; &nbsp; <a survery_question_id="<{$index}>"  href="javascript:;" class="del_survery_question">点击删除</a></div>
						</div>
				<{/if}>
				
				
				<{if $survery_question.type=='txt'}>
						<div class="panel panel-default" style="padding: 10px;">
						<{*<div style="margin: 10px;">排序:  &nbsp; &nbsp; &nbsp; <{$index}></div>*}>
						<div style="margin: 10px;">问题:   &nbsp; &nbsp; &nbsp; <{$survery_question.question}></div>
						<div style="margin: 10px;">类型:  &nbsp; &nbsp; &nbsp; 文字</div>
							<div style="clear:both;"></div>
							<{foreach from=$survery_question.answer key=key  item=answer}>
								<div style="text-align:left;margin:10px;"><{$answer.answer}></div>
							<{/foreach}>
							<div style="margin: 10px;">操作:  &nbsp; &nbsp; &nbsp; <a survery_question_id="<{$index}>"  href="javascript:;" class="del_survery_question">点击删除</a></div>
						</div>
				<{/if}>
				
				
				
				
				<{/foreach}>
				
			</div>
		</div>
		<div  style="text-align:right; margin-right: 20px;margin-bottom: 10px;"><a href="?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>&typ=question"><i class="fa fa-plus"></i>添加一个问题</a></div>
	</div>
	
</div>

<{include file="./admin/activity/common_right.html"}>

<div style="clear:both;"></div>
</form>
</div>


<script>
KISSY.use('node, io, event, jquery', function (S, Node, IO, Event, jQuery) {
	var $ = S.all;
	
	$(".del_survery_question").on('click', function () {
    	  var survery_question_id = $(this).attr('survery_question_id');
    	  var events_id = <{$events_Data.events.id}>;
    	  var formData = {'survery_question_id':survery_question_id,'events_id':events_id};
    	  new IO({
  			type: "post"
  			, url: VG.conf.root_domain + '/?c=Admin_Activity_SetInteractive&a=ReqDelSurveyQuestion'
  			, data: formData
  			, success: function (data) {
  				if (data.ok) { //ok
  					var url = data.msg;
  					location.href = VG.conf.root_domain + '?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>';
  				} else {
  					alert('操作失败,原因:'+data.msg);
  				}
  				return false;
  			}
  			, error: function (NULL, textStatus) {
  				alert("请求服务器失败,原因:"+textStatus);
  			}
  			, dataType: "json"
  		});
    	  
	});
	
	
	
	
	$(".del_survery_prize").on('click', function () {
  	  var survery_prize_id = $(this).attr('survery_prize_id');
  	  var events_id = <{$events_Data.events.id}>;
  	  var formData = {'survery_prize_id':survery_prize_id,'events_id':events_id};
  	  
  	  new IO({
			type: "post"
			, url: VG.conf.root_domain + '/?c=Admin_Activity_SetInteractive&a=ReqDelSurveyPrize'
			, data: formData
			, success: function (data) {
				if (data.ok) { //ok
					var url = data.msg;
					location.href = VG.conf.root_domain + '?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>';
				} else {
					alert('操作失败,原因:'+data.msg);
				}
				return false;
			}
			, error: function (NULL, textStatus) {
				alert("请求服务器失败,原因:"+textStatus);
			}
			, dataType: "json"
		});
  	  
	});
	
	
	
});
</script>

<{include file="./admin/bottom.html"}>