<div ng-controller="UserListCtrl" class="wrapper">
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="form-inline">
				<button ng-click="add()" class="btn btn-default">
					<i class="glyphicon glyphicon-plus"> 添加</i>
				</button>
				<button ng-click="showUploadModal()" class="btn btn-default" ng-if="userType">
					<i class="glyphicon glyphicon-import"> 导入</i>
				</button>
				<button ng-click="expForClient()" class="btn btn-default" ng-if="1 != 1 && userType">
					<i class="glyphicon glyphicon-export"> 客户端导出</i>
				</button>
				<div class="input-group col-sm-3">
		      		<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
					<input type="text" class="form-control" ng-model="search.keyword" placeholder="姓名或登录名" ng-change="goPage(1)" />
				</div>
			</div>
			<div>
			<form id="downloadForm" action="#"></form>
			</div>
			<table class="table table-striped">
				<thead>
					<tr>
						<th nowrap="nowrap">序号</th>
						<th nowrap="nowrap">DB</th>
						<th nowrap="nowrap">登录名</th>
						<th nowrap="nowrap">姓名</th>
						<th nowrap="nowrap">性别</th>
						<th nowrap="nowrap" ng-if="showFullInfo">职称</th>
						<th nowrap="nowrap" ng-if="showFullInfo">单位</th>
						<th nowrap="nowrap" ng-if="showFullInfo">院系</th>
						<th nowrap="nowrap" ng-if="showMajor">专业</th>
						<th nowrap="nowrap">办公电话</th>
						<th nowrap="nowrap">手机</th>
						<th nowrap="nowrap" ng-if="!userType">角色</th>
						<th nowrap="nowrap" nowrap="nowrap" ng-if="userType == userTypes.teacher">关联课程</th>
						<th nowrap="nowrap" nowrap="nowrap">状态</th>
						<th>操作</th>
					</tr>										
				</thead>
				<tbody>
					<tr ng-repeat="row in pageModel.array">
						<td>{{$index+1}}</td>
						<td>{{row.id}}</td>
						<td>{{row.loginName}}</td>
						<td>{{row.name}}</td>
						<td>{{row.gender}}</td>
						<td ng-if="showFullInfo">{{row.position}}</td>
						<td ng-if="showFullInfo">{{row.school}}</td>
						<td ng-if="showFullInfo">{{row.department}}</td>
						<td ng-if="showMajor">{{row.major}}</td>
						<td>{{row.officePhone}}</td>
						<td>{{row.phone}}</td>
						<td ng-if="!userType" class="col-sm-2">{{row.roleString}}</td>
						<td class="col-sm-2" ng-if="userType == userTypes.teacher">
							<span ng-repeat="course in row.courses" class="m-l">{{course.code}} - {{course.name}}</span>
						</td>
						<td class="{{row.isEnabled == 1 ? 'text-success' : 'text-danger'}}">{{row.isEnabled | userStatus}}</td>
						<td>
							<button ng-click="edit(row.id)" class="btn btn-default btn-xs">
								<i class="glyphicon glyphicon-edit"> 编辑</i>								
							</button>							
							<button ng-click="resetPassword(row.id)" class="btn btn-info btn-xs">
								<i class="glyphicon glyphicon-lock"> 重置密码</i>								
							</button>		
							<button ng-click="showRelatedCoursesModal(row)" class="btn btn-default btn-xs" ng-if="userType == userTypes.teacher">
								<i class="glyphicon glyphicon-paperclip"> 关联课程</i>
							</button>					
						</td>
					</tr>
				</tbody>

			</table>
			<nav ng-if="pageModel.totalPage > 1">
				<ul class="pagination">
					<li class="{{pageModel.curPage == 1 ? 'disabled' : ''}}" ng-click="goPage(pageModel.curPage - 1)">
						<a aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
			      	</li>
				    <li ng-repeat="i in [9,8,7,6,5,4,3,2,1]" ng-if="pageModel.curPage - i > 0" ng-click="goPage(pageModel.curPage - i)">
				    	<a>{{pageModel.curPage - i}}</a>
			    	</li>
				    <li class="active"><a href="#">{{pageModel.curPage}}</a></li>
				    <li ng-repeat="i in [1,2,3,4,5,6,7,8,9]" ng-if="pageModel.curPage + i <= pageModel.totalPage" ng-click="goPage(pageModel.curPage + i)">
				    	<a>{{pageModel.curPage + i}}</a>
			    	</li>
				    <li class="{{pageModel.curPage == pageModel.totalPage ? 'disabled' : ''}}" ng-click="goPage(pageModel.curPage + 1)">
				      	<a aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
				    </li>
				</ul>
			</div>
			
		</div>
	</div>
</div>