<html xmlns="http://www.w3.org/1999/xhtml">
<!--#include file="../Inc/Conn.asp" -->
<!--#include file="../Inc/SK.Session.asp" -->
<!--#include file="../Inc/SK.Funtion.asp" -->
<%if Not (getconfig("SK_Office")="0" AND (Session("Manager")="1" OR (JudgePopedomTF(Session("UserName"),"SK100000000") AND JudgePopedomTF(Session("UserName"),"SK100000600") AND JudgePopedomTF(Session("UserName"),"SK100000601")))) then Call ReturnError()%>
<%
'AddNew
if RQ("Action")="Add" and F("S_Di")<>"" and F("S_Title")<>"" and F("S_Atime")<>"" then
Call ChkIsOuter()
set rs=server.createobject("adodb.recordset")
sql="select * from SK_OfficeReim"
rs.open sql,conn,1,3
rs.AddNew
rs("SK_Di")=NoCSSHackInput(F("S_Di"))
rs("SK_Title")=NoCSSHackInput(F("S_Title"))
rs("SK_Content")=NoCSSHackContent(F("S_Content"))
rs("SK_Atime")=NoCSSHackInput(F("S_Atime"))
rs("SK_Feet")="0"
rs("SK_ShUID")="0"
rs("SK_ShFeet")="0"
rs("SK_SalesID")=Session("UID")
rs("SK_Addor")=Session("UserName")
rs("SK_Time")=Now()
rs("SK_Del")="0"

'自定义字段部分开始
set RsField=Server.createobject("adodb.recordset")
sqlField="SELECT * from SK_OfficeFields where SK_Di=1 and SK_ShowOnForm=0"
RsField.Open sqlField,conn,1,1
A=0
while not RsField.eof
A=A+1
rs(""&RsField("SK_FieldName")&"")=NoCSSHackInput(F(""&RsField("SK_FieldName")&""))
RsField.movenext
wend
RsField.close
Set RsField=Nothing

set RsOption=Server.createobject("adodb.recordset")
sqlOption="SELECT * from SK_OfficeOptions where SK_Di=1 and SK_ShowOnForm=0"
RsOption.Open sqlOption,conn,1,1
B=0
while not RsOption.eof
B=B+1
rs(""&RsOption("SK_FieldName")&"")=NoCSSHackInput(F(""&RsOption("SK_FieldName")&""))
RsOption.movenext
wend
RsOption.close
Set RsOption=Nothing
'自定义字段部分结束

rs.Update

set rs=conn.execute("select @@IDENTITY")
GetNewID=rs(0)
rs.Close 
set rs=Nothing

if request("S_AA").count>0 then
for i =1 to request("S_AA").count
set rs1=server.createobject("adodb.recordset")
sql1="select * from SK_OfficeReimDetail"
rs1.open sql1,conn,1,3
if request("S_AA")(i)<>"" and request("S_Amount")(i)<>"" then
rs1.AddNew
'--------------------------------------------------------
rs1("SK_ReimID")=GetNewID
rs1("SK_AA")=request("S_AA")(i)
rs1("SK_Amount")=request("S_Amount")(i)
rs1("SK_Time")=Now()
'--------------------------------------------------------
rs1.Update
end if

rs1.Close
set rs1=Nothing
next
end if

'Event Begin
if getconfig("SK_Event")=0 then
set rsEvent=server.createobject("adodb.recordset")
sqlEvent="select * from SK_SystemEvent"
rsEvent.open sqlEvent,conn,1,3
rsEvent.AddNew
rsEvent("SK_Title")="新建费用报销"
rsEvent("SK_User")=Session("UserName")
rsEvent("SK_Time")=Now()
rsEvent("SK_IP")=request.ServerVariables("Remote_Addr")
rsEvent.Update
rsEvent.Close 
set rsEvent=Nothing
end if
'Event End
Response.Write("<script LANGUAGE='javascript'>alert('恭喜你,操作成功！');window.close();window.opener.location.reload();</script>")
Response.End
end if
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>新建费用报销</title>
<META http-equiv=Page-Enter content=SKCRM>
<META http-equiv=Page-Exit content=SKCRM>
<META content="MSHTML 6.00.3790.2858" name=GENERATOR>
<LINK href="../images/style.css" type=text/css rel=stylesheet>
<script language="javascript" src="../Inc/Check.js"></script>
<script language="javascript" src="../Inc/Calendar.js"></script>
<script language="javascript" src="../Inc/jquery.js"></script>
<SCRIPT language=javascript src="../inc/Openwin.js"></SCRIPT>
<script>
window.onbeforeunload = function()
{
if (document.body.offsetWidth-50 < event.clientX && event.clientY<0)
{
return "是否关闭当前窗口？关闭本窗口将放弃申请费用！";
}
}
</script>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x: hidden;
}
-->
</style>
<SCRIPT language=JavaScript>
function Form1_Validator(theForm)
{

if(form1.S_Title.value ==""){
alert("对不起,报销主题不能为空!");
form1.S_Title.focus();
return false;
}

if(form1.S_Di.value ==""){
alert("对不起,请选择报销类别!");
form1.S_Di.focus();
return false;
}

if(form1.S_Atime.value ==""){
alert("对不起,报销日期不能为空!");
form1.S_Atime.focus();
return false;
}

return true;
}
</SCRIPT>
</head>
<body>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
<TBODY>
<tr>
<td class="SK_Td_Top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12" height="25"><img src="../images/tab_03.gif" width="12" height="25" /></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="46%" valign="middle">新建费用报销</td>
<td width="54%"></td>
</tr>
</table></td>
<td width="16"><img src="../images/tab_07.gif" width="16" height="25" /></td>
</tr>
</table></td>
</tr>
<tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="8" background="../images/tab_12.gif"></td>
<td>

<form name="thisForm" id="form1" method="post" action="?Action=Add" onSubmit="return Form1_Validator(this)"> 
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">
<tr>
  <td class="SK_Text2">报销主题</td>
  <td width="37%" class="SK_Text1"><input name="S_Title" type="text" size="40"> <font color=red>*</font></td>
  <td width="9%" class="SK_Text2">报销类别</td>
  <td width="40%" class="SK_Text1"><select name="S_Di">
<option value="" selected>---请选择---</option>
<%
Set rs1=Server.CreateObject("ADODB.RecordSet") 
sql1="SELECT * from SK_SystemCategory where SK_Di=144 order by CategoryID asc" 
rs1.Open sql1,conn,1,1
do while not rs1.eof
%><option value="<%=rs1("CategoryID")%>"><%=rs1("SK_Name")%></option>
<%
rs1.movenext
loop
rs1.close
set rs1=Nothing
%></select> <font color=red>*</font></td>
</tr>
<tr>
  <td width="14%" class="SK_Text2">报销日期</td>
  <td colspan="3" class="SK_Text1"><input name="S_Atime" type="text" size="12" value="<%=Date()%>" onClick="new Calendar().show(this);" readOnly /> <font color=red>*</font></td>
  </tr>
<tr>
  <td valign="top" class="SK_Text2">费用列表</td>
  <td colspan="3" class="SK_Text1">
<!--相关费用开始 -->
<TABLE width="100%" border=1 align="center" cellPadding=3 cellSpacing=0 borderColor=#ffffff borderColorLight=#dfdfdf borderColorDark="#ffffff" id="itemList">
<TBODY>
<TR>
<TD width="6%" class="Pheadtd">选择</TD>
<TD width="8%" class="Pheadtd">编号</TD>
<TD width="60%" class="Pheadtd">用途</TD>
<TD width="26%" class="Pheadtd">金额</TD>
</TR>
					  
<TR id="row1">
<TD class="Ptetd"><input type="checkbox" name="cbRow" value="0" style="border:0"></TD>
<TD class="Ptetd"><div id="rowNum">1</div></TD>
<TD class="Ptetd"><input name="S_AA" type="text" class="input" size="40"></TD>
<TD class="Ptetd"><input name="S_Amount" type="text" size="15" onKeyPress="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value;if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false" onKeyUp="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" onBlur="if(!this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?|\.\d*?)?$/))this.value=this.o_value;else{if(this.value.match(/^\.\d+$/))this.value=0+this.value;if(this.value.match(/^\.$/))this.value=0;this.o_value=this.value};" maxlength="15"></TD>
</TR>
</TBODY>
</TABLE>
<script>   
  //初始化时,自动新建6行
  window.onload = function(){
   for(var j=0;j<0;j++){
  add_row();
   }
  }
  //新建一行
  function add_row()   
  {
      var con = row1.cloneNode(true);   
      var newTR=con;   
      newTR.style.display='';     //加的   
      newTR.id="row" + document.getElementById('itemList').rows.length-1;
      row1.parentNode.insertAdjacentElement("beforeEnd",newTR);   
      newTR.cells[1].innerHTML = '<div align=center>' + (document.getElementById('itemList').rows.length-1) + '';
  }
  //删除一行
  function del_row()   
  {   
      if( !confirm("你确定要删除吗?") )
          return;
      if(itemList.rows.length==1)
      {   
          alert("没有可以删除的对象了!");   
          return;   
      }   
      var  checkit   =   false;
      var deleteRowIndex = new Array();
      for(var   i=0;i<document.all.cbRow.length;i++)   {   
         if(document.all.cbRow[i].checked)   {        
            checkit=true;   
            deleteRowIndex[i] = i;
         }   
     }
   var tmpIndex = 0;
   for( var x=0;x<deleteRowIndex.length;x++ ){
  //alert( deleteRowIndex[x] );
  if( deleteRowIndex[x] && deleteRowIndex[x] != "" ){
   itemList.deleteRow(deleteRowIndex[x]+1-tmpIndex) ;
   tmpIndex++;
  }
   }
   if(!checkit)     
   {   
    alert("请选择一个要删除的对象!");   
    return   false   
   }
   //重新设置行ID和序号
   for( var y=1;y<document.getElementById('itemList').rows.length;y++ ){
  document.getElementById('itemList').rows[y].id = 'row' + y;
  document.getElementById('itemList').rows[y].cells[1].innerHTML = '<div align=center>' + y + '';
   }
  }
   </script>
<table width="100%" border=1 align="center" cellPadding=3 cellSpacing=0 borderColor=#ffffff borderColorLight=#dfdfdf borderColorDark="#ffffff">
<TR>
  <TD colspan="4" class="Ptetd1"><input type="button" class="button1" value="增加行" onclick="add_row()">
        <input type="button" class="button1" value="删除行" onclick="del_row()" /></TD>
  </TR>
</table>

<!--相关费用结束 -->
  </td>
</tr>
<tr>
  <td valign="top" class="SK_Text2">报销备注</td>
  <td colspan="3" valign="top" class="SK_Text1"><IFRAME ID="eWebEditor1" SRC="<%=getconfig("SK_EditorPath")%>/ewebeditor.htm?id=S_Content&style=mini" FRAMEBORDER="0" SCROLLING="no" WIDTH="600" HEIGHT="300"></IFRAME>
<input type="hidden" name="S_Content"></td>
</tr>
<%
'自定义选项开始
set RsOptions=server.createobject("adodb.recordset")
sqlOptions="SELECT * from SK_OfficeOptions where SK_Di=1 and SK_ShowOnForm=0 Order by SK_OrderID asc"
RsOptions.Open sqlOptions,conn,1,1
if RsOptions.bof and RsOptions.eof then
else
%>
<tr>
  <td colspan="4" class="SK_Title1">自定义选项</td>
  </tr>
<tr>
  <td colspan="4" class="SK_Text1">
<%
Response.write"<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""1"">"
for Optionsi=1 to RsOptions.recordCount '变量i从1循环到数据库中的全部记录数 
if (Optionsi mod 2 =1) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "<tr>" 
end if
Response.write"<td class=""SK_Text2"" width=""14%"">"&RsOptions("SK_Title")&"</td><td class=""SK_Text1""><select name="&RsOptions("SK_FieldName")&">"

Set rs1=Server.CreateObject("ADODB.RecordSet") 
sql1="SELECT * from SK_OfficeOptionsDetail where SK_OptionsID="&RsOptions("FieldID")&"" 
rs1.Open sql1,conn,1,1
Response.write"<option value="""" selected>--请选择--</option>"
do while not rs1.eof
Response.write"<option value="&rs1("OptionsDetailID")&">"&rs1("SK_OName")&"</option>"
rs1.movenext
loop
rs1.close
set rs1=Nothing

Response.write"</select></td>"
if (Optionsi mod 2 = 0) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "</tr>" 
end if 
RsOptions.movenext 
next 
Response.write"</table>"
%>
</td>
</tr>
<%
end if
RsOptions.close
set RsOptions=Nothing
'自定义选项结束
'自定义字段开始
set RsFields=server.createobject("adodb.recordset")
sqlFields="SELECT * from SK_OfficeFields where SK_Di=1 and SK_ShowOnForm=0 Order by SK_OrderID asc"
RsFields.Open sqlFields,conn,1,1
if RsFields.bof and RsFields.eof then
else
%>
<tr>
  <td colspan="4" class="SK_Title1">自定义字段</td>
  </tr>
<tr>
  <td colspan="4" class="SK_Text1">
<%
Response.write"<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""1"">"
for Fieldsi=1 to RsFields.recordCount '变量i从1循环到数据库中的全部记录数 
if (Fieldsi mod 2 =1) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "<tr>" 
end if
Response.write"<td class=""SK_Text2"" width=""14%"">"&RsFields("SK_Title")&"</td><td class=""SK_Text1""><input type=""text"" size=""20"" name="&RsFields("SK_FieldName")&" title="&RsFields("SK_Tips")&"></td>"
if (Fieldsi mod 2 = 0) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "</tr>" 
end if 
RsFields.movenext 
next 
Response.write"</table>"
%>
</td>
</tr>
<%
end if
RsFields.close
set RsFields=Nothing
'自定义字段结束
%>
<tr>
<td colspan="4" class="SK_Text">
<INPUT class="button1" type="submit" value=" 保存 "> 
<input type="button" value=" 关闭 " onClick="window.opener.location.reload();window.close();" class="button1" /></td>
</tr>
</table>
</form>

</td>
<td width="8" background="../images/tab_15.gif"></td>
</tr>
</table></td>
</tr>
<tr>
<td class="SK_Td_Foot">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" height="20"><img src="../images/tab_18.gif" width="12" height="20" /></td>
<td width="98%" class="SK_Td_Page"></td>
<td width="1%"><img src="../images/tab_20.gif" width="16" height="20" /></td>
</tr>
</table>
	
</td>
</tr>
</TBODY>
</table>
</body>
<%
Call CloseDB()
%>
</html>