<!-- 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 'admin_menu' -->
					</ul>
				</div>
			</div>
			<div class="adminContent autoHeight">
				<div class="subNav">
					<ul class="navTabs">
						<li><a href="/holidaygroup">审批组</a></li>
						<li class="active"><a href="/hcsgroup">抄送人</a></li>
						<li><a href="/holidayadmin">假期管理</a></li>
					</ul>
				</div>
				<legend>添加抄送人</legend>
				<table class="table table-striped">
					<thead>
					<tr>
						<th>组描述</th>
						<th>成员</th>
						<th>抄送人</th>
						<th>审批组操作</th>
					</tr>
					</thead>
					<tbody>
					<!-- if isset({{approverlist}}) && !empty({{approverlist}}) -->
					<!-- loop approverlist -->
					<tr>
						<td>{{approverlist' value.typename}}</td>
						<td>{{approverlist' value.name}}</td>
						<td>
							<!-- if isset({{approverlist' value.csmsg}}) && !empty({{approverlist' value.csmsg}}) -->
							<!-- loop approverlist' value.csmsg -->
							{{approverlsit' csmsg' value.csname}}<a href="#del" onclick='delapproval("{{approverlist' value.id}}","{{approverlsit' csmsg' value.csidname}}:{{approverlsit' csmsg' value.csname}}:{{approverlsit' csmsg' value.cspinyinname}}")' data-toggle="modal" role="button" title="删除" class="icon-">k</a> &nbsp;
							<!-- endloop -->
							<!-- endif -->
						</td>
						<td><a href="#add" data-toggle="modal" onclick="setapproval('{{approverlist' value.id}}')">添加抄送人</a></td>
					</tr>
					<!-- endloop -->
					<!-- endif -->
					</tbody>
				</table>
			</div>
		</div>
	</div>
<!--弹出（添加抄送人）-->
<div class="modal hide fade" id="add">

  <div class="modal-dialog">
    <div class="modal-content">
    <div class="modal-header">
    <h3>添加抄送人</h3>
    </div>
		<form method="post" action="/addhcsgroup">
			<input type="hidden" name="approvalid" id="approvalid" value="">
    <div class="modal-body">
    	<div class="control-group">
    		<div class="controls">
			    <select style="width:190px" id="category">
					<!-- loop category -->
			    	<option value="{{category' value.cid}}" <!-- if {{category' value.cid}} == 12 -->selected<!-- endif -->>{{category' value.title}}</option>
					<!-- endloop -->
			    </select>
			    <select style="width:190px" id="cidstaff" name="cidstaff">
					<!-- loop zongbu -->
			    	<option value="{{zongbu' value.sid}}:{{zongbu' value.username}}:{{zongbu' value.wxid}}">{{zongbu' value.username}}</option>
			    	<!-- endloop -->
			    </select>
			</div>
		</div>
    </div>
	<div class="modal-footer">
	    <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
	    <button class="button" type="submit">确定</button>
	</div>
		</form>
</div>
</div>
</div>
<!--弹出-->
<!--弹出（删除抄送人）-->
<div class="modal hide fade" id="del">

  <div class="modal-dialog">
    <div class="modal-content">
    <div class="modal-header">
    <h3>确认删除</h3>
    </div>
    <div class="modal-body">
    	<p>删除后，正在使用该审批组的假期审批将不受影响，可继续接收抄送通知。</p>
    </div>
		<form method="post" action="/delhcsgroup">
			<input type="hidden" name="approvalid" id="approvalid2" value="">
			<input type="hidden" name="cidstaff" id="delcsstaff" value="">
	<div class="modal-footer">
	    <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a>
	    <button class="button" type="submit">确定</button>
	</div>
		</form>
</div>
</div>
</div>
<!--弹出-->
<script type="text/javascript">autoFlashHeight();</script>
<script>
	$(function(){
		$('#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 = '';
						$.each(result.stafflist,function(k,v){
							html +='<option value="'+v.sid+':'+v.username+':'+v.wxid+'">'+v.username+'</option>';
						})
						$('#cidstaff').html(html);
					}
				}
			})
		})
	});

	function setapproval(id){
		$('#approvalid').val(id);
	}

	function delapproval(id,csstaff){
		$('#approvalid2').val(id);
		$('#delcsstaff').val(csstaff);
	}

</script>
</body>
