{% extends 'TopxiaWebBundle:CourseManage:layout.html.twig' %}

{% block title %}价格设置 - {{ parent() }}{% endblock %}

{% set side_nav = 'price' %}
{% set script_controller = 'course-manage/price' %}
{% block main %}

<div class="panel panel-default panel-col">
	<div class="panel-heading">价格设置
	</div>
	<div class="panel-body">
		{{ web_macro.flash_messages() }}

		{% if canModifyPrice %}
		
			<form class="form-horizontal" id="price-form" method="post" action="{{path('course_manage_price',{id:course.id})}}">

				<div class="form-group">
					<div class="col-md-2 control-label">
						<label for="price">价格</label>
					</div>
					<div class="col-md-8 controls">
						<input type="text" id="price" name="price" class="form-control" value="{{course.price}}">
						<div class="help-block" style="display:none;"></div>
					</div>
				</div>
				
				{% if setting('coin.coin_enabled') %}
				<div class="form-group">
					<div class="col-md-2 control-label">
						<label for="coinPrice"> {{setting('coin.coin_name')}}价格</label>
					</div>
					<div class="col-md-8 controls">
						<input type="text" id="coinPrice" name="coinPrice" class="form-control" value="{{course.coinPrice}}">
						<div class="help-block" style="display:none;"></div>
					</div>
				</div>
				{% endif %}

				{% if is_feature_enabled('free_limit') %}
				<div class="form-group">
					<div class="col-md-2 control-label">
						<label for="freeStartTime">限免开始时间</label>
					</div>
					<div class="col-md-8 controls">
						<input type="text" id="freeStartTime" name="freeStartTime" class="form-control" value="{{course.freeStartTime|default()|data_format('Y-m-d H:i')}}">
						<div class="help-block" style="display:none;" id="start-help-block"></div>
					</div>
				</div>

				<div class="form-group">
					<div class="col-md-2 control-label">
						<label for="freeEndTime">限免结束时间</label>
					</div>
					<div class="col-md-8 controls">
						<input type="text" id="freeEndTime" name="freeEndTime" class="form-control" value="{{course.freeEndTime|default()|data_format('Y-m-d H:i')}}">
						<div class="help-block" style="display:none;"></div>
					</div>
				</div>
				{% endif %}

				{% if setting('vip.enabled') %}

				<div class="form-group">
					<div class="col-md-2 control-label">
						<label for="price">会员课程设置</label>
					</div>
					<div class="col-md-8 controls">
					  <select name="vipLevelId" class="form-control width-input width-input-large">
					  	{{ select_options(levels, course.vipLevelId, '无') }}
					  </select>
						<div class="help-block">设置会员课程后，该会员及更高等级会员，可免费学习。</div>
					</div>
				</div>
				{% endif %}


				<div class="form-group">
					<div class="col-md-offset-2 col-md-8 controls">
						<button class="btn btn-fat btn-primary" id="price-save-btn" type="submit">保存</button>
					</div>
				</div>

				<input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

			</form>
		{% else %}
		  <div class="alert alert-danger">抱歉，您无权设置课程价格，如有需要请联系网站管理员！</div>
		{% endif %}
	</div>
</div>

{% endblock %}