<!-- include 'header' -->
<body>
	<div class="mainLayout">
		<div class="mainMenu">
			<div class="menuItem">
				<a href="#" class="mLogo">CLD</a>
				<ul>
					<!-- include 'menu' -->
				</ul>
			</div>
		</div>
		<div class="warpContent">
			<div class="subMenu fL">
				<div class="menuItem">
					<ul>
						<!-- include 'holiday_menu' -->
					</ul>
				</div>
			</div>
			<div class="adminContent autoHeight" style="height: 821px;">
				<legend><div class="fR"><a class="button" href="#addVacation" data-toggle="modal">休假登记</a></div>休假管理</legend>
				<div class="demandCate">
					<ul class="cateList">
						<li>
							<select id="selectcid">
								<option value="all">所有办事处</option>
								<!-- loop category -->
								<option value="{{category' value.cid}}" <!-- if isset({{thiscid}}) && {{category' value.cid}} == {{thiscid}} -->selected<!-- endif -->>{{category' value.title}}</option>
								<!-- endloop -->
							</select>
						</li>
						<!--<li><select><option>2017</option></select> <select><option>1月</option><option>2月</option></select></li>-->
	  				</ul>
	  			</div>
				<div class="saeaList">
					<div class="entry">
						<table class="table table-bordered table-condensed table-hover">
							<tbody>
							<tr>
								<th class="taC" width="50"></th>
								<th class="taC">员工</th>
								<th class="taC">年假周期</th>
								<th class="taC">年假<sub>（可用）</sub></th>
								<th class="taC">婚假<sub>（可用）</sub></th>
								<th class="taC">产假<sub>（可用）</sub></th>
								<!--<th class="taC">存假<sub>（可用）</sub></th>-->
								<th class="taC">丧假<sub>（可用）</sub></th>
								<th class="taC">工伤假<sub>（可用）</sub></th>
							</tr>
							<!-- loop stafflist -->
							<!-- loop stafflist' value.cidstafflist -->
							<tr>
								<!-- if !empty({{stafflist' cidstafflist' value.first}}) -->
								<th rowspan="{{stafflist' value.count}}">{{stafflist' value.categoryname}}</th>
								<!-- endif -->
								<th>{{stafflist' cidstafflist' value.username}}</th>
								<td class="taC">{{stafflist' cidstafflist' value.yearround}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.yearnum}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.hunjianum}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.chanjianum}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.sangjianum}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.gongjianum}}</td>
								<!--<td class="taC">{{stafflist' cidstafflist' value.username}}</td>-->
							</tr>
							<!-- endloop -->
							<!-- endloop -->
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--弹出-->
<div class="modal hide fade" id="addVacation">
	<div class="modal-dialog ">
		<div class="modal-content">
			<div class="modal-header">
				<h3>休假登记</h3>
			</div>
			<form action="/setstaffholiday" method="post" onsubmit="return setholidaynum();">
			<div class="modal-body saeaList">
				<table class="table table-bordered table-condensed">
					<tbody>
					<tr>
						<th class="taC" width="100"><span class="colRed">*</span>员工</th>
						<td>
							<select id="category">
								<!-- loop category -->
								<option value="{{category' value.cid}}">{{category' value.title}}</option>
								<!-- endloop -->
							</select>
							<select id="cidstaff" name="uid">
								<option value="0">选择员工</option>
								<!-- loop zongbu -->
								<option value="{{zongbu' value.sid}}">{{zongbu' value.username}}</option>
								<!-- endloop -->
							</select>
						</td>
					</tr>
					<tr>
						<th class="taC" width="100"><span class="colRed">*</span>登记类型</th>
						<td>
							<select id="selectholiday" name="typeholiday">
								<option value="yearnum">年假</option>
								<option value="hunjianum">婚假</option>
								<option value="chanjianum">产假</option>
								<option value="sangjianum">丧假</option>
								<option value="gongjianum">工伤假</option>
							</select>
						</td>
					</tr>
					<tr>
						<th class="taC" width="100">当前天数</th><td><span id="thisnum">{{thisnum}}</span> 天</td>
					</tr>
					<tr>
						<th class="taC" width="100"><span class="colRed">*</span>增加天数</th><td><input placeholder="请输入天数" id="addnum" name="addnum" type="number" step="0.5"></td>
					</tr>
					<tr>
						<th class="taC" width="100">备注</th><td><textarea class="span4" name="description" placeholder="选填"></textarea></td>
					</tr>
					</tbody>
				</table>
			</div>
			<div class="modal-footer">
				<a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">取消</a>
				<button type="submit" class="button">确定</button>
			</div>
			</form>
		</div>
	</div>
</div>
    <!--弹出内容-->
<script type="text/javascript">autoFlashHeight();</script>
<script>
	$(function(){
		$('#selectcid').change(function(){
			var html = '';
			if($(this).val() != 'all'){
				html += '/'+$(this).val();
			}
			window.location.href = '/holidayvacation'+html;
		});

		$('#category').change(function(){
			$.ajax({
				type: 'post',
				url: '/getstaffcategory',
				data: {cid:$(this).val()},
				dataType: 'json',
				success: function(result){
					if(result.code == 200){
						$('#cidstaff').html('');
						var html = '<option value="0">选择员工</option>';
						$.each(result.stafflist,function(k,v){
							html +='<option value="'+v.sid+'">'+v.username+'</option>';
						});
						$('#cidstaff').html(html);
						$('#selectholiday option[value="yearnum"]').prop('selected',true);
						$('#thisnum').text(result.thisnum);
					}
				}
			})
		});

		$('#cidstaff').change(function(){
			$.ajax({
				type: 'post',
				url: '/getholidaystaff',
				data: {uid:$(this).val(),type:$('#selectholiday').val()},
				dataType: 'json',
				success: function(result){
					if(result.code == 200){
						$('#thisnum').text(0);
						$('#thisnum').text(result.thisnum);
					}
				}
			})
		});

		$('#selectholiday').change(function(){
			$.ajax({
				type: 'post',
				url: '/getholidaystaff',
				data: {uid:$('#cidstaff').val(),type:$(this).val()},
				dataType: 'json',
				success: function(result){
					if(result.code == 200){
						$('#thisnum').text(0);
						$('#thisnum').text(result.thisnum);
					}
				}
			})
		});
	});
	function setholidaynum(){
		if($('#cidstaff').val() == 0){
			alert('请选择员工');
			return false;
		}
		if($('#addnum').val() == ''){
			alert('请输入增加天数');
			return false;
		}
	}
</script>
</body>
</html>
