<!-- 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="#addOvertime" 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 id="year">
								{{option}}
							</select>
							<select id="month">
								<option value="1" <!-- if {{thismonth}} == 1 -->selected<!-- endif -->>1月</option>
								<option value="2" <!-- if {{thismonth}} == 2 -->selected<!-- endif -->>2月</option>
								<option value="3" <!-- if {{thismonth}} == 3 -->selected<!-- endif -->>3月</option>
								<option value="4" <!-- if {{thismonth}} == 4 -->selected<!-- endif -->>4月</option>
								<option value="5" <!-- if {{thismonth}} == 5 -->selected<!-- endif -->>5月</option>
								<option value="6" <!-- if {{thismonth}} == 6 -->selected<!-- endif -->>6月</option>
								<option value="7" <!-- if {{thismonth}} == 7 -->selected<!-- endif -->>7月</option>
								<option value="8" <!-- if {{thismonth}} == 8 -->selected<!-- endif -->>8月</option>
								<option value="9" <!-- if {{thismonth}} == 9 -->selected<!-- endif -->>9月</option>
								<option value="10" <!-- if {{thismonth}} == 10 -->selected<!-- endif -->>10月</option>
								<option value="11" <!-- if {{thismonth}} == 11 -->selected<!-- endif -->>11月</option>
								<option value="12" <!-- if {{thismonth}} == 12 -->selected<!-- endif -->>12月</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 colGreen">加班</th><th class="taC colGreen">值班</th><th class="taC colRed">补休</th><th class="taC">调休</th><th class="taC">累计存假 <span class="icon- colBlue" data-placement="bottom" data-toggle="ctooltip" data-original-title="累计存假=加班+值班">h</span></th><th class="taC">剩余存假  <span class="icon- colBlue" data-placement="bottom" data-toggle="ctooltip" data-original-title="剩余存假=累计存假-补休-提现">h</span></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.4}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.5}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.10}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.11}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.countnum}}</td>
								<td class="taC">{{stafflist' cidstafflist' value.addnum}}</td>
							</tr>
							<!-- endloop -->
							<!-- endloop -->
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--弹出-->
<div class="modal hide fade" id="addOvertime">
	<div class="modal-dialog ">
		<div class="modal-content">
	    <div class="modal-header">
	    	<h3>加班登记</h3>
	    </div>
			<form method="post" action="/addholiday" onsubmit="return addholiday();">
	    <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="selecttype" name="type">
						<option value="5">值班登记</option>
						<option value="4">加班登记</option>
						<option value="13">存假提现</option>
					</select></td>
				</tr>
				<!--值班-->
				<tr id="tr_5" class="changetr">
					<th class="taC" width="100"><span class="colRed">*</span>值班日期</th><td><input id="zhiban" name="day" placeholder="请选择值班日期" type="date"></td>
				</tr>
				<!--加班-->
				<tr id="tr_4" class="changetr" style="display: none">
					<th class="taC" width="100"><span class="colRed">*</span>加班日期</th><td><input id="jiaban" name="day" placeholder="请选择加班日期" type="date" disabled="true"></td>
				</tr>
				<!--提现-->
				<tr id="tr_13" class="changetr" style="display: none">
					<th class="taC" width="100"><span class="colRed">*</span>提现天数</th><td><input id="tixian" name="tixian" placeholder="请输入提现天数" type="number" step="0.5" disabled="true"></td>
				</tr>
				<tr id="tr_day">
					<th class="taC" width="100"><span class="colRed">*</span>时间</th>
					<td>
						<select name="daytype">
							<option value="1">全天（1天）</option>
							<option value="2">上午（0.5天）</option>
							<option value="3">下午（0.5天）</option>
						</select>
					</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();
			}
			html += '/year/'+$('#year').val()+'/month/'+$('#month').val();
			window.location.href = '/holidayovertime' + html;
		});

		$('#year').change(function(){
			var html = '';
			if($('#selectcid').val() != 'all') {
				html += '/' + $('#selectcid').val();
			}
			html += '/year/'+$(this).val()+'/month/'+$('#month').val();
			window.location.href = '/holidayovertime' + html;
		});

		$('#month').change(function(){
			var html = '';
			if($('#selectcid').val() != 'all') {
				html += '/' + $('#selectcid').val();
			}
			html += '/year/'+$('#year').val()+'/month/'+$(this).val();
			window.location.href = '/holidayovertime' + 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);
					}
				}
			})
		});

		$('#selecttype').change(function(){
			$('.changetr').hide();
			$('.changetr input').attr('disabled',true);
			$('#tr_'+$(this).val()).show();
			$('#tr_'+$(this).val()+' input').removeAttr('disabled');
			if($(this).val() == 13){
				$('#tr_day').hide();
				$('#tr_day').find('select').attr('disabled',true);
			}else{
				$('#tr_day').show();
				$('#tr_day').find('select').removeAttr('disabled');
			}
		})
	});

	function addholiday(){
		if($('#cidstaff').val() == 0){
			alert('请选择员工');
			return false;
		}
		if($('#selecttype').val() == 4){
			if($('#jiaban').val() == ''){
				alert('请选择加班日期');
				return false;
			}
		}else if($('#selecttype').val() == 5){
			if($('#zhiban').val() == ''){
				alert('请选择值班日期');
				return false;
			}
		}else if($('#selecttype').val() == 13) {
			if ($('#tixian').val() == '') {
				alert('请输入提现天数');
				return false;
			}
		}
	}
</script>
</body>
