<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=GBK">
  <link rel="stylesheet" type="text/css" href="fb_client.css">
</head>
<script>
function calc(em_id) {
  var row = em_id.split("_")[1];

  var name = document.getElementById("name_" + row);
  if(name.value == "") return;

  var article = document.getElementById("article_" + row);
  var periods = document.getElementById("periods_" + row);
  var prePayment = document.getElementById("prePayment_" + row);
  var allPayment = document.getElementById("allPayment_" + row);
  var writeDownRate = document.getElementById("writeDownRate_" + row);
  var draw = document.getElementById("draw_" + row);
  var writeDown = document.getElementById("writeDown_" + row);
  var taxableIncome = document.getElementById("taxableIncome_" + row);
  var taxRate = document.getElementById("taxRate_" + row);
  var quickDeduction = document.getElementById("quickDeduction_" + row);
  var finalTax = document.getElementById("finalTax_" + row);

  if(article.value == "001") periods.value = 1;
  else if(article.value == "002") periods.value = 3;
  else if(article.value == "003") periods.value = 12;
  else if(article.value == "004") periods.value = 12;
  else if(article.value == "005") periods.value = 1;

  autoFloat(prePayment);
  autoFloat(allPayment);

  if(atof(prePayment.value) > atof(allPayment.value)) allPayment.value = prePayment.value;
  if(atof(prePayment.value) == atof(allPayment.value)) writeDownRate.value = 1;
  else writeDownRate.value = bto_scale(prePayment.value/allPayment.value,2);

  autoFloat(draw);
  if(atof(prePayment.value) == atof(allPayment.value)) writeDown.value = bto_scale(draw.value,2);
  else writeDown.value = bto_scale(draw.value * prePayment.value/allPayment.value,2);

  taxableIncome.value = bto_scale(draw.value - writeDown.value,2);

  var rate = getRate1(taxableIncome.value/periods.value);
  taxRate.value = rate[0];
  quickDeduction.value = rate[1];

  finalTax.value = bto_scale((taxableIncome.value/periods.value * taxRate.value - quickDeduction.value) * periods.value,2);
}

function default_text(field, article) {
  if(field == "begin") return getLastMonthB();

  if(field == "end") return getLastMonthE();

  if(field == "name") return "";

  if(field == "codeType") return "06";

  if(field == "code") return "";

  if(field == "article") return "001";

  if(field == "remark") return "";

  return "0.00";
}

function help_text(field, article) {
  if(field == "name") return "纳税人身份证件上面的名称，请如实填写。";

  if(field == "codeType") return "[01 - 护照]、[02 - 通行证]、[03 - 回乡证]、[04 - 台胞证]、[05 - 旅行证]、[06 - 身份证]、[07 - 军官证]、<br>[08 - 税务管理码]、[09 - 特殊类别]、[10 - 纳税人识别号]、[11 - 士兵证]、[90 - 其他]";

  if(field == "code") return "纳税人身份证件上面的号码，请如实填写。";

  if(field == "article") return "[001 - 按月领取]、[002 - 按季领取]、[003 - 按年领取]、[004 - 一次性领取（特殊原因）]、[005 - 一次性领取（无特殊原因）]。";

  if(field == "periods" || field == "writeDownRate" || field == "writeDown" || field == "taxableIncome" || field == "taxRate" || field == "quickDeduction" || field == "finalTax") return "自动计算。";

  if(field == "status") return "自动生成。";

  if(field == "begin" || field == "end") return "请按yyyyMMdd日期格式，如实填写。";

  return "请如实填写。";
}

function del_new(em) {
  var row = em.id.split("_")[1];
  var s = document.getElementById("statusC_" + row);
  if(s.value == "") return;
  
  var flag;
  if(s.value.substring(0,1) == "-") {
    s.value = s.value.substring(1,s.value.length);
    flag = false;
    document.getElementById("del_" + row).innerText = "删除";
  } else {
    s.value = "-" + s.value;
    flag = true;
    document.getElementById("del_" + row).innerText = "恢复";
  }
  var ips = em.parentElement.parentElement.all.tags("input");
  for(var i=1;i<ips.length;i++) {
    ips[i].disabled = flag;
  }
}

function del(em) {
  var ips = em.parentElement.parentElement.all.tags("input");
  for(var i=1;i<ips.length;i++) {
    ips[i].value = "";
  }
}

function _del() {
  if(document.getElementById("flag3").value != "0") {
    var d = document.getElementById("del_" + document.getElementById("flag3").value);
    var r = document.getElementById("row_" + document.getElementById("flag3").value);
    r.value = "";
    del(d);
  }
}

function __valid() {
  if(document.getElementById("flag2").value != "0") {
    var ips = document.all.tags("input");
    for(var i=1;i<ips.length;i++) {
      if(ips[i].disabled) {
        ips[i].disabled = false;
      }
    }
    ips = document.all.tags("button");
    for(var i=1;i<ips.length;i++) {
      if(ips[i].innerText == "恢复") {
        ips[i].innerText = "删除"
      }
    }
    for(var i=1;i<=20;i++){
      var s = document.getElementById("statusC_"+i);
      if(s.value != "" && s.value != "0"){         
        document.getElementById("status_"+i).style.color = "red";
        document.getElementById("name_" + i).style.color = "red";
      }else{
        document.getElementById("name_" + i).style.color = "black";
      }
    }
  }
}
</script>
<body>
<input type="hidden" id="flag2" value="0" onpropertychange="__valid()">
<input type="hidden" id="flag3" value="0" onpropertychange="_del()">
<input type="hidden" id="reportType" value="5">
<div style="border:1px solid gray;padding:2px">
<div align="center" class="title">个 人 所 得 税 申 报 （ 领 取 年 金 所 得 明 细 数 据 ）</div>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td style="padding:6px 0px 6px 0px;">
      <button onclick="WebBrowser.ExecWB(6,1)">打 印</button>&nbsp;
      <button onclick="WebBrowser.ExecWB(7,1)">打印预览</button>&nbsp;
      <button onclick="WebBrowser.ExecWB(8,1)">打印设置</button>&nbsp;
      <span>
        缩放比例：
        <select id="bodySize" onchange="changeBodySize(this)">
          <option value="1.00">100%</option>
          <option value="0.80">80%</option>
          <option value="0.70">70%</option>
          <option value="0.50">50%</option>
          <option value="0.40">40%</option>
          <option value="0.35">35%</option>
          <option value="0.30">30%</option>
        </select>
      </span>
    </td>
    <td align="left">编制单位：<input id="cname" style="width:320px;text-align:left" readonly></td>
    <td align="right">金额单位：元（列至角分）</td>
  </tr>
</table>
<table cellspacing="0" cellpadding="0" style="border-collapse:collapse" border="1" bordercolor="gray" id="main">
  <tr class="bg1" valign="bottom">
    <th nowrap>&nbsp;序号&nbsp;<br><br></th>
    <th nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>A</th>
    <th nowrap>证件<br>类型<br>B</th>
    <th nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;证件号码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>C</th>
    <th nowrap>领取<br>方式<br>D</th>
    <th nowrap>分摊<br>比例<br>E</th>
    <th nowrap>所得起始<br>日期<br>F</th>
    <th nowrap>所得终止<br>日期<br>G</th>
    <th nowrap>2014年前<br>&nbsp;&nbsp;缴费金额&nbsp;&nbsp;<br>H</th>
    <th nowrap>全部<br>&nbsp;&nbsp;缴费金额&nbsp;&nbsp;<br>I</th>
    <th nowrap>减计<br>比例<br>J=H/I</th>
    <th nowrap>支付<br>&nbsp;年金金额&nbsp;<br>K</th>
    <th nowrap>允许减计<br>的金额<br>L=K*H/I</th>
    <th nowrap>&nbsp;应纳税所得额&nbsp;<br>M=K-L</th>
    <th nowrap>&nbsp;适用&nbsp;<br>税率<br>N</th>
    <th nowrap>速算<br>&nbsp;扣除数&nbsp;<br>O</th>
    <th nowrap>&nbsp;&nbsp;应纳税额&nbsp;&nbsp;<br>P=(M/E*N-O)*E</th>
    <th nowrap style="width:160px;">备注<br>Q</th>
    <th nowrap style="width:320px;">审核<a name="_valid_"></a><br><br></th>
    <th nowrap valign="center">操作</th>
  </tr>
  <script>
    for(var i=1;i<=20;i++) {
      document.write("<tr>");
      document.write("<td><input             id='row_" + i +"'  value='" + i +"' style='text-align:center' readonly></td>");
      document.write("<td><input             id='name_" + i +"'           maxlength='32'></td>");
      document.write("<td><input             id='codeType_" + i +"'       maxlength='2'  class='acenter'></td>");
      document.write("<td><input             id='code_" + i +"'           maxlength='18'></td>");
      document.write("<td><input             id='article_" + i +"'        maxlength='3'  class='acenter'></td>");
      document.write("<td class='bg1'><input id='periods_" + i +"'                       class='acenter bg1' readonly></td>");
      document.write("<td><input             id='begin_" + i +"'          maxlength='8'  class='acenter'></td>");
      document.write("<td><input             id='end_" + i +"'            maxlength='8'  class='acenter'></td>");
      document.write("<td><input             id='prePayment_" + i +"'     maxlength='12' class='aright'></td>");
      document.write("<td><input             id='allPayment_" + i +"'     maxlength='12' class='aright'></td>");
      document.write("<td class='bg1'><input id='writeDownRate_" + i +"'                 class='aright bg1' readonly></td>");
      document.write("<td><input             id='draw_" + i +"'           maxlength='12' class='aright'></td>");
      document.write("<td class='bg1'><input id='writeDown_" + i +"'                     class='aright bg1' readonly></td>");
      document.write("<td class='bg1'><input id='taxableIncome_" + i +"'                 class='aright bg1' readonly></td>");
      document.write("<td class='bg1'><input id='taxRate_" + i +"'                       class='aright bg1' readonly></td>");
      document.write("<td class='bg1'><input id='quickDeduction_" + i +"'                class='aright bg1' readonly></td>");
      document.write("<td class='bg1'><input id='finalTax_" + i +"'                      class='aright bg1' readonly></td>");
      document.write("<td><input             id='remark_" + i +"'         maxlength='18'></td>");
      document.write("<td class='bg1'><input id='status_" + i +"'  class='bg1'  readonly style='color:red;'>");
      document.write("                <input id='statusC_" + i +"' type='hidden' value='0'></td>");
      document.write("<td><button            id='del_" + i +"'         onclick='del_new(this)'>删除</button></td>");
      document.write("</tr>");
    }
  </script>
</table>
<table border="0" width="100%">
  <tr>
    <td style="padding-top:4px">
      <span style="width:99px"><span id="ss1">共0条记录</span></span>
      <span style="width:50px">第<span id="ss2">1</span>页</span>
      <span style="width:50px">共<span id="ss3">1</span>页</span>
      &nbsp;<button id="b1">首页</button>
      &nbsp;<button id="b2">上页</button>
      &nbsp;<button id="b3">下页</button>
      &nbsp;<button id="b4">尾页</button>
      &nbsp;<button id="b6">转至</button>
      &nbsp;<input  id="ppp" style="width:40px;border:1px solid gray">&nbsp;页
      &nbsp;&nbsp;<button id="b11">分项汇总</button>
      &nbsp;&nbsp;<button id="b5">显示全部</button>
      &nbsp;&nbsp;<button onclick="_valid();document.body.scrollLeft=10000;">校验本页</button>
      &nbsp;&nbsp;<button id="b12">插入记录</button>
      &nbsp;&nbsp;<button onclick="help_html()">帮助手册</button>
      &nbsp;&nbsp;<button id="b9">设置单位</button>
      &nbsp;&nbsp;<button id="b10">模糊查询</button>
    </td>
  </tr>
</table>
</div>
<script src="fb_client.js"></script>
</body>
</html>