<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="cm" uri="/commons-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>员工考勤配置</title>
<link href="../resources/style/base.css" rel="stylesheet" type="text/css"/>
<s:include value="../common/head.jsp" />
<script language="javascript" src="../code/vm/ExtCodeJs.htm"></script>
<script type="text/javascript">
function batchAdd(){
	iframeWindow("<s:url action='attEmplConfBatchAdd'/>", 550,400,"批量新增考勤配置",refreshWindow);
}

function typeAdd(){
	if(getCheckedCount("sid")!=1){
		msgAlert("请选择一条您要新增考勤配置的员工记录。");
		return;
	}
	iframeWindow("<s:url action='attEmplConfOperate'/>?oper=add&conf.emplInfo.id="+getCheckedValue("sid"),
		450,400,"新增考勤配置",refreshWindow);
}

function typeEdit(){
	if(getCheckedCount("sid")!=1){
		msgAlert("请选择一条您要修改的记录。");
		return;
	}
	var confId=gi("conf_id_"+getCheckedValue("sid")).value;
	if(confId==""){
		msgAlert("该员工目前还没有考勤配置信息，请点击 “新增考勤配置” 按钮为该员工配置考勤信息。");
		return;
	}
	iframeWindow("<s:url action='attEmplConfOperate'/>?oper=edit&conf.id="+confId,450,400,"修改当前配置",refreshWindow);
}


function typeDel(){
	if(getCheckedCount("sid")!=1){
		msgAlert("请选择一条您要删除的记录。");
		return;
	}
	var confId=gi("conf_id_"+getCheckedValue("sid")).value;
	if(confId==""){
		msgAlert("该员工目前还没有考勤配置信息，无需删除。");
		return;
	}
	msgConfirm("您确认要删除该员工的当前考勤配置信息吗？删除当前配置记录后将启用原来的考勤配置。",function(){
		iframeWindow("<s:url action='attEmplConfOperate'/>?oper=delete&conf.id="+confId,400,200,"删除当前配置",refreshWindow);
	});
}

function setHistory(){
	if(getCheckedCount("sid")!=1){
		msgAlert("请选择一条您要查看历史配置的员工记录。");
		return;
	}
	var confId=gi("conf_id_"+getCheckedValue("sid")).value;
	if(confId==""){
		msgAlert("该员工目前还没有考勤配置信息，无需查看考勤历史配置信息。");
		return;
	}
	iframeWindow("<s:url action='attEmplConfOperate'/>?oper=history&conf.emplInfo.id="+getCheckedValue("sid"),650,400,"考勤历史配置",refreshWindow);
}

</script>
</head>

<body>
<div class="body_list">
  <s:include value="../common/body.jsp" />
  <s:form action="attEmplConfList" id="queryForm" onsubmit="return checkForm(this)">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_line">
      <tr class="form_title">
        <td colspan="6">查询条件</td>
      </tr>
      <tr class="form_item">
        <td>工号：
          <s:textfield name="conf.emplInfo.emplNo" title="工号必须为数字。" cssStyle="width:100px;"/></td>
        <td>部门：
          <s:textfield name="conf.emplInfo.emplOrg.name" readonly="true" onClick="codeTree('emplOrgTree',gi('eimpOrgId'),this)" cssStyle="width:100px;" cssClass="find_input"/>
          <s:hidden name="conf.emplInfo.emplOrg.id" id="eimpOrgId"/></td>
        <td>考勤类型：
          <s:select cssStyle="width:100px;" 
            	name="conf.worktimeType.id" list='#request.SysCodeFinder.find("ATT_WORKTIME_TYPE")' 
                headerKey="" headerValue="" listKey="id" listValue="codeName"/></td>
        <td align="center"><s:checkbox name="showOffJob" fieldValue="true"/> 显示离职员工</td>
      </tr>
      <tr class="form_item1">
        <td width="24%">姓名：
          <s:textfield name="conf.emplInfo.name" cssStyle="width:100px;"/></td>
        <td width="28%">状态：
          <s:select cssStyle="width:100px;" name="confFlag" list="#{'true':'已配置', 'false':'未配置'}" headerKey="" headerValue=""/></td>
        <td width="29%">是否打卡：
          <s:select cssStyle="width:100px;"  name="conf.isNeedSign.id"  list='#request.SysCodeFinder.find("YES_NO")'  headerKey="" headerValue="" listKey="id" listValue="codeName"/></td>
        <td width="19%" align="center"><input name="q" value="查 询" onclick="query()" type="button" /></td>
      </tr>
    </table>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  style="margin:15px 0 5px 0;" >
      <tr>
        <td>
		  
		  <input type="button" name="add" onclick="typeAdd()" value="新增配置"/>
          <input type="button" name="edit" onclick="typeEdit()" value="修改当前配置"/>
          <input type="button" name="edit" onclick="typeDel()" value="删除当前配置"/>
           <input type="button" name="edit" onclick="setHistory()" value="查看历史配置"/> 
		   <input type="button" name="add" onclick="batchAdd()" value="批量新增配置"/>
         </td>
      </tr>
    </table>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_line">
      <tr class="list_title">
        <td width="3%" align="center"><input type="radio" name="array" onclick="checkedAll(this,'sid')" value="checkbox" /></td>
        <td width="7%">工号</td>
        <td width="7%">姓名</td>
        <td width="20%">部门</td>
        <td width="7%">状态</td>
        <td width="8%">考勤类型</td>
        <td width="18%">考勤班次</td>
        <td width="14%">是否需要打卡</td>
        <td width="16%">生效日期</td>
      </tr>
      <s:iterator value="emplConfList" status="st">
        <s:set name="row_cls" value=""/>
        <s:if test="#st.Even">
          <s:set name="row_cls" value="%{'row_a'}"/>
        </s:if>
        <tr class="list_data <s:property value='#row_cls'/>">
          <td align="center"><input type="radio" name="array" value="<s:property value='top[0].id'/>" lang="sid"/>
            <input id="conf_id_<s:property value='top[0].id'/>" type="hidden" value="<s:property value='top[1].id'/>" /></td>
          <td class="center"><s:property value="top[0].emplNo"/></td>
          <td class="center"><s:property value="top[0].name"/></td>
          <td><s:property value="top[0].emplOrg.fullName"/></td>
          <td class="center">
		  	<s:if test="top[1]==null">
				未配置
			</s:if>
			<s:else>
				已配置
			</s:else>
		  </td>
          <td class="center"><s:property value="top[1].worktimeType.codeName"/>&nbsp;</td>
          <td class="center"><s:property value="top[1].worktimeConf.name"/>
            &nbsp;</td>
          <td class="center"><s:property value="top[1].isNeedSign.codeName"/>&nbsp;</td>
          <td class="center"><s:date name="top[1].beginDate" format="yyyy-MM-dd"/>&nbsp;</td>
        </tr>
      </s:iterator>
    </table>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="list_page">
      <tr>
        <td><cm:pager/></td>
      </tr>
    </table>
  </s:form>


 <s:if test="worktimeConfList!=null && worktimeConfList.size()>0">
 <table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin:5px 0;">
  <tr>
    <td><a href="javascript:showHide('timeDetail')">[查看班次时间明细]</a></td>
  </tr>
 </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_line" 
  		style="display:none;" id="timeDetail"> 
    <tr>
      <td  style="padding-bottom:10px;">
        <s:iterator value="worktimeConfList">
        <table width="130" border="0" cellspacing="0" cellpadding="0" style="border:1px #CCC solid; margin:10px; float:left;">
          <tr class="sub_list_title">
            <td valign="top">
            	<span style="background-color:<s:property value='color'/>; border:1px #999 solid;"><s:property value='code'/></span>
                &nbsp;<s:property value='name'/>
            </td>
          </tr>
          <s:iterator value="periodSet">
          <tr class="list_data">
            <td><s:property value="beginTime"/>&nbsp;至&nbsp;<s:property value="dateType.codeName"/><s:property value="endTime"/>
            </td>
          </tr>
          </s:iterator> 
        </table>
        </s:iterator>
      </td>
    </tr>
  </table>
  </s:if>

  
</div>
</body>
</html>