<%@ 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="../resources/js/calendar/calendar.js"></script>
</head>

<body>
<s:include value="../common/body.jsp" />
<script language="javascript">
var tempHtml="";
var rowIndex=0;
$(function(){
	tempHtml="<tbody>"+$("#row_template").html()+"</tbody>";
	$("#row_template").html("");
	initRows();
});
function addRow(amt,rate,amtSub){
	var thtml=tempHtml.replace("taxAmt_name","detList["+rowIndex+"].taxAmt").replace("taxRate_name","detList["+rowIndex+"].taxRate")
					  .replace("taxSub_name","detList["+rowIndex+"].taxSub");
	var $row=$(thtml);
	$row.children("tr").attr("id","row_"+rowIndex);
	$row.find("#amt").val(amt);		
	$row.find("#rate").val(rate);	
	$row.find("#amtSub").val(amtSub);			
	$row.find("#delImg").attr("rel",rowIndex);
	$("#row_body").append($row.html());
	rowIndex++;
}
function delRow(ix){
	$("#row_"+ix).html("");
}
function initRows(){
  	<s:iterator value="taxRate.detSet">
  		addRow("<s:property value='taxAmt'/>","<s:property value='taxRate'/>","<s:property value='taxSub'/>");
  	</s:iterator>
	//default add one
	if(rowIndex==0)addRow();
}

function otherCheck(){
	if($("#row_body").find("#amt").size()<1){
		msgAlert("操作失败，请添加个人所得税率记录。");
		return false;
	}
	return true;
}
</script>

<s:form action="salaryTaxRateOperate" namespace="/salary"  onsubmit="return checkForm(this,otherCheck)">

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr class="form_tr">
      <td align="right"><span class="required">•</span>启用月份：</td>
      <td valign="top">
      		<s:textfield name="taxRate.beginMonth" readonly="true" onClick="showCalendar('yyyyMM',this)" 
            	cssClass="date_input" cssStyle="width:180px;" title="启用月份 为必填项。" />
      </td>
    </tr>
    <tr class="form_tr">
      <td align="right" valign="top">终止月份：</td>
      <td valign="top" style="padding-bottom:0;">
            		<s:textfield name="taxRate.endMonth" readonly="true" onClick="showCalendar('yyyyMM',this)" 
            	cssClass="date_input" cssStyle="width:180px;"/>
        <div class="info" style="margin:5px 0;">终止月份为空表示一直启用。</div>
      </td>
    </tr>
    <tr class="form_tr">
      <td align="right"><span class="required">•</span>起征金额：</td>
      <td valign="top">
           <s:textfield name="taxRate.startAmt" title="起征金额为必填项，且必须为合法的金额格式。" cssStyle="width:180px;"/>
      </td>
    </tr>
    <tr class="form_tr">
      <td colspan="2" align="center" style="padding-bottom:0;">
        <table width="380" border="0" cellpadding="0" cellspacing="0" class="sub_table_line">
          <tr class="sub_list_title center">
            <td width="141">应纳税所得额</td>
            <td width="85">税率(小数)</td>
            <td width="104">速算扣除数</td>
            <td width="48">操作</td>
          </tr>
          <tbody id="row_template">
              <tr class="list_data center">
                <td>超过 <s:textfield id="amt" name="taxAmt_name" title="应纳税所得额为必填项，且必须为合法的金额格式。" cssStyle="width:70px;text-align:right;"/> 元</td>
                <td><s:textfield id="rate" name="taxRate_name" title="税率为必填项，且最多3位小数。" cssStyle="width:60px;text-align:right;"/></td>
                <td><s:textfield id="amtSub" name="taxSub_name" title="速算扣除数为必填项，且必须为合法的金额格式。" cssStyle="width:70px;text-align:right;"/> 元</td>
                <td><img id="delImg" src="../resources/images/del.gif" width="14" height="12" class="pointer" onclick="delRow(this.rel)" /></td>
              </tr>
          </tbody>
          <tbody id="row_body"></tbody>
      </table>
		<table width="380" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td style="padding-top:3px; padding-right:0;"><div class="sub_add" style="margin-left:0; float:right;" onclick="addRow()">新增</div></td>
          </tr>
        </table>        
      </td>
    </tr>
    <tr class="form_tr">
      <td width="38%" align="right">&nbsp;</td>
      <td width="62%" valign="top" style="padding-bottom:0;">
        <s:if test="oper=='edit'">
          <input type="submit" name="button" id="button" value="修 改" />
          </s:if>
        <s:if test="oper=='add'">
          <input type="submit" name="button" id="button" value="添 加" />
          </s:if>
        &nbsp; 
        <!-- back begin -->
        <input name="winID" type="hidden" value="${param.winID}" />
        <input type="button" onclick="iframeWindowClose('${param.winID}')" name="button" id="button" value="返 回" />  
        <!-- back end -->
        <s:hidden name="taxRate.id" />
        <s:hidden name="oper" />
        </td>
    </tr>
  </table>
</s:form>
</body>
</html>