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

{% block title %}基础信息 - {{ parent() }}{% endblock %}

{% set script_controller = 'settings/profile' %}
{% set side_nav = 'profile' %}

{% block main %}

	{% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {class:'panel-col'} %}
		{% block heading %}基础信息{% endblock %}
		{% block body %}
			
			{% if fromCourse %}
			<div class="alert alert-info">设置头衔、自我介绍并保存后，即可开始创建课程。</div>
			{% endif %}

			<form id="user-profile-form" class="form-horizontal" method="post">
				{{ web_macro.flash_messages() }}
					{% if 'ROLE_TEACHER' not in app.user.roles and 'ROLE_PARENT' not in app.user.roles %}
						<div class="form-group">
							<label class="col-md-2 control-label" >学号</label>
							<div class="col-md-7 controls">
								<div class="control-text">
									{{app.user.number|default('')}}
								</div>
							</div>
						</div>
					{% endif %}

					<div class="form-group">
						<label class="col-md-2 control-label" for="profile_truename">姓名</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_truename" name="profile[truename]" class="form-control" value="{{ app.user.truename|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{# {% if app.user.isParent() %}
						<div class="form-group">
							<label class="col-md-2 control-label" for="profile_mobile">手机号码</label>
							<div class="col-md-7 controls">
								<input type="text" id="profile_mobile" name="profile[mobile]" data-url="{{path('admin_user_create_mobile_check')}}" class="form-control" value="{{ app.user.mobile|default('') }}" >
								<div class="help-block" style="display:none;"></div>
							</div>
						</div>
					{% endif %} #}

					{% if 'ROLE_TEACHER' not in app.user.roles and 'ROLE_PARENT' not in app.user.roles %}
						<div class="form-group">
							<label class="col-md-2 control-label" >所在班级</label>
							<div class="col-md-7 controls">
								<div class="control-text">
									{% if classes %}
										{{ class_name(classes)|default('') }}
									{% else %}
										尚未加入任何班级
									{% endif %}	
								</div>
							</div>
						</div>
					{% endif %}

					<div class="form-group">
						<label class="col-md-2 control-label">性别</label>
						<div class="col-md-7 controls radios">
							<div id="profile_gender">
								<input type="radio" id="profile_gender_0" name="profile[gender]" required="required" value="male" {% if profile.gender == 'male' %}checked="checked"{% endif %}>
								<label for="profile_gender_0" class="required">男</label>
								<input type="radio" id="profile_gender_1" name="profile[gender]" required="required" value="female" {% if profile.gender == 'female' %}checked="checked"{% endif %}>
								<label for="profile_gender_1" class="required">女</label>
							</div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">头衔</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_title" name="profile[title]" class="form-control" value="{{ profile.title|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div> 

					<div class="form-group">
						<label class="col-md-2 control-label">个人签名</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_signature" name="profile[signature]" class="form-control" value="{{ profile.signature|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">自我介绍</label>
						<div class="col-md-7 controls">
							<textarea name="profile[about]" rows="10" id="profile_about" class="form-control">{{ profile.about|default('') }}</textarea>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">个人主页</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_site" name="profile[site]" class="form-control" data-widget-cid="widget-4" data-explain="" value="{{ profile.site|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<div class="col-md-2 control-label">
							<label for="weibo">微博</label> 
						</div>
						<div class="col-md-7 controls">
							<input type="text" id="weibo" name="profile[weibo]" class="form-control" data-widget-cid="widget-3" data-explain="" value="{{ profile.weibo|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">微信</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_weixin" name="profile[weixin]" class="form-control" value="{{ profile.weixin|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>       

					<div class="form-group">
						<label for="profile_qq" class="col-md-2 control-label">QQ</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_qq" name="profile[qq]" class="form-control" data-widget-cid="widget-2" data-explain="" value="{{ profile.qq|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>



					{% if fields %}
					<hr>
					{% for field in fields %}
					{% if field.type=="text" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<textarea id="{{field.fieldName}}" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control">{{ profile[field.fieldName]|default('') }}</textarea>
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="int" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" placeholder="最大值为9位整数" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control"  value="{{ profile[field.fieldName]|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="float" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" placeholder="保留到2位小数" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control"  value="{{ profile[field.fieldName]|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="date" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" name="profile[{{field.fieldName}}]" class="{{field.type}} form-control" value="{% if profile[field.fieldName] %}{{profile[field.fieldName]}}{% endif %}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% elseif field.type=="varchar" %}
					<div class="form-group">
						<label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
						<div class="col-md-7 controls">
							<input type="text" id="{{field.fieldName}}" name="profile[{{field.fieldName}}]" class="form-control" value="{{ profile[field.fieldName]|default('') }}">
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					{% endif %}
					{% endfor %}
					{% endif %}

					<div class="row">
						<div class="col-md-7 col-md-offset-2">
							<button id="profile-save-btn" data-submiting-text="正在保存" type="submit" class="btn btn-primary">保存</button>
						</div>
					</div>

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

		{% endblock %}
	{% endembed %}
{% endblock %}