<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_Sales")="0" AND (Session("Manager")="1" OR (JudgePopedomTF(Session("UserName"),"SK300000000") AND JudgePopedomTF(Session("UserName"),"SK310000202")))) then Call ReturnError()%>
<%
if not isnumeric(JCID(F("ID"))) then Call ReturnError10()
set rs=server.createobject("adodb.recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql="SELECT * from SK_ItemContract where ItemContractID="&JCID(F("ID"))&""
elseif Session("Manager")=3 then
sql="SELECT * from SK_ItemContract where SK_ItemContract.ItemContractID="&JCID(F("ID"))&""
elseif Session("Manager")=4 then
sql="SELECT * from SK_ItemContract where SK_ItemContract.ItemContractID="&JCID(F("ID"))&""
elseif Session("Manager")=5 then
sql="SELECT * from SK_ItemContract where SK_ItemContract.ItemContractID="&JCID(F("ID"))&""
elseif Session("Manager")=6 then
sql="SELECT * from SK_ItemContract where SK_SalesID="&Session("UID")&" and ItemContractID="&JCID(F("ID"))&""
end if
rs.Open sql,conn,1,1
if rs.eof and rs.bof then Call ReturnError4()

'Mod
if RQ("Action")="Mod" and F("S_Di")<>"" and F("S_ClientID")<>"" and F("S_Title")<>"" and F("S_ContractNo")<>"" and F("S_ContractTime")<>"" then
Call ChkIsOuter()
set rs=server.createobject("adodb.recordset")
sql="select * from SK_ItemContract where ItemContractID="&JCID(F("ID"))&""
rs.open sql,conn,1,3
rs("SK_Di")=NoCSSHackInput(F("S_Di"))
rs("SK_ClientID")=NoCSSHackInput(F("S_ClientID"))
rs("SK_ItemContractNo")=NoCSSHackInput(F("S_ContractNo"))
rs("SK_ItemContractTitle")=NoCSSHackInput(F("S_Title"))
rs("SK_ItemContractTime")=NoCSSHackInput(F("S_ContractTime"))
rs("SK_Feet")=NoCSSHackInput(F("S_Feet"))
rs("SK_Currency")=NoCSSHackInput(F("S_Currency"))
rs("SK_Amount")=NoCSSHackInput(F("S_Amount"))
rs("SK_Atime")=NoCSSHackInput(F("S_Atime"))
rs("SK_Btime")=NoCSSHackInput(F("S_Btime"))
rs("SK_Aname")=NoCSSHackInput(F("S_Aname"))
rs("SK_Atel")=NoCSSHackInput(F("S_Atel"))
rs("SK_Bname")=NoCSSHackInput(F("S_Bname"))
rs("SK_Btel")=NoCSSHackInput(F("S_Btel"))
rs("SK_Content")=NoCSSHackContent(F("S_Content"))
rs("SK_Editor")=Session("UID")
rs("SK_Etime")=Now()

'自定义部分开始
set RsField=Server.createobject("adodb.recordset")
sqlField="SELECT * from SK_SalesFields where SK_Di=9 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_SalesOptions where SK_Di=9 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
rs.Close 
set rs=Nothing

'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")="修改项目销售合同："&NoCSSHackInput(F("S_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_Client.value ==""){
alert("对不起,请选择关联客户!");
form1.S_Client.focus();
return false;
}

if(form1.S_ContractNo.value ==""){
alert("对不起,合同编号不能为空!");
form1.S_ContractNo.focus();
return false;
}

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

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

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

if(form1.S_Feet.value ==""){
alert("对不起,请选择合同状态!");
form1.S_Feet.focus();
return false;
}

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

if(form1.S_Amount.value ==""){
alert("对不起,项目金额不能为空!");
form1.S_Amount.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=Mod" onSubmit="return Form1_Validator(this)"> 
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">

<tr>
  <td width="12%" class="SK_Text2">关联客户</td>
  <td width="35%" class="SK_Text1"><input name="S_Client" type="text" size="30" value="<%
set rsClient=server.createobject("adodb.recordset")
sqlClient="select * from SK_Client where ClientID="&Rs("SK_ClientID")&""
rsClient.open sqlClient,conn,1,1
Response.write""&RsClient("SK_Wname")&""
RsClient.close
Set RsClient=Nothing
%>" readonly>
<input name="S_ClientID" type="hidden" value="<%=Rs("SK_ClientID")%>"><a onClick="JavaScript:window.open('../Client/SK.SeMyClient.asp','SClinet','directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=820,height=400,top=176,left=161');" style="cursor:hand"><img src="../images/sclient.gif" /></a> <font color=red>*</font>
 <input name="S_Linkman" type="hidden">
  <input name="S_LinkmanID" type="hidden"></td>
  <td width="12%" class="SK_Text2">合同编号</td>
  <td width="41%" class="SK_Text1"><input name="S_ContractNo" type="text" size="20" value="<%=Rs("SK_ItemContractNo")%>"> <font color=red>*</font></td>
</tr>
<tr>
  <td class="SK_Text2">合同主题</td>
  <td class="SK_Text1"><input name="S_Title" type="text" size="35" value="<%=Rs("SK_ItemContractTitle")%>"> <font color=red>*</font></td>
  <td class="SK_Text2">签约日期</td>
  <td class="SK_Text1"><input name="S_ContractTime" type="text" size="12" onClick="new Calendar().show(this);" value="<%=Rs("SK_ItemContractTime")%>" readOnly /> <font color=red>*</font></td>
</tr>
<tr>
  <td class="SK_Text2">合同类别</td>
  <td class="SK_Text1"><select name="S_Di">
<%
set rsDi = server.createobject("adodb.recordset")
rsDi.open "SELECT * from SK_SystemCategory where SK_Di=47",conn,1,1
for Di=1 to rsDi.recordcount
selected=""
if rs("SK_Di")=rsDi("CategoryID") then selected="selected='selected'"
response.Write("<option "&selected&" value="&rsDi("CategoryID")&">"&rsDi("SK_Name")&"</option>")
rsDi.movenext
next
rsDi.close
set rsDi=Nothing
%></select> <font color=red>*</font></td>
  <td class="SK_Text2">合同状态</td>
  <td class="SK_Text1"><select name="S_Feet">
<option value="0" <%if Rs("SK_Feet")="0" then Response.Write("selected")%>>未签约</option>
<option value="1" <%if Rs("SK_Feet")="1" then Response.Write("selected")%>>已签约</option>
<option value="2" <%if Rs("SK_Feet")="2" then Response.Write("selected")%>>生效中</option>
<option value="3" <%if Rs("SK_Feet")="3" then Response.Write("selected")%>>已失效</option>
</select> <font color=red>*</font></td>
</tr>
<tr>
  <td class="SK_Text2">货币类别</td>
  <td class="SK_Text1"><select name="S_Currency">
<%
set rsCurrency = server.createobject("adodb.recordset")
rsCurrency.open "SELECT * from SK_SystemCategory where SK_Di=142",conn,1,1
for DD=1 to rsCurrency.recordcount
selected=""
if rs("SK_Currency")=rsCurrency("CategoryID") then selected="selected='selected'"
response.Write("<option "&selected&" value="&rsCurrency("CategoryID")&">"&rsCurrency("SK_Name")&"</option>")
rsCurrency.movenext
next
rsCurrency.close
set rsCurrency=Nothing
%></select> <font color=red>*</font></td>
  <td class="SK_Text2">合同金额</td>
  <td class="SK_Text1"><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" value="<%=Rs("SK_Amount")%>"> <font color=red>*</font></td>
</tr>
<tr>
  <td class="SK_Text2">我方代表</td>
  <td class="SK_Text1"><input name="S_Aname" type="text" size="15" value="<%=Rs("SK_Aname")%>"></td>
  <td class="SK_Text2">客户代表</td>
  <td class="SK_Text1"><input name="S_Bname" type="text" size="15" value="<%=Rs("SK_Bname")%>"></td>
</tr>
<tr>
  <td class="SK_Text2">我方电话</td>
  <td class="SK_Text1"><input name="S_Atel" type="text" size="18" value="<%=Rs("SK_Atel")%>"></td>
  <td class="SK_Text2">客户电话</td>
  <td class="SK_Text1"><input name="S_Btel" type="text" size="18" value="<%=Rs("SK_Btel")%>"></td>
</tr>
<tr>
  <td class="SK_Text2">开始日期</td>
  <td class="SK_Text1"><input name="S_ATime" type="text" size="12" onClick="new Calendar().show(this);" value="<%=Rs("SK_Atime")%>" readOnly /></td>
  <td class="SK_Text2">结束日期</td>
  <td class="SK_Text1"><input name="S_BTime" type="text" size="12" onClick="new Calendar().show(this);" value="<%=Rs("SK_Btime")%>" readOnly /></td>
</tr>

<tr>
  <td valign="top" class="SK_Text2">合同描述</td>
  <td colspan="3" class="SK_Text1"><IFRAME ID="eWebEditor1" SRC="<%=getconfig("SK_EditorPath")%>/ewebeditor.htm?id=S_Content&style=mini" FRAMEBORDER="0" SCROLLING="no" WIDTH="600" HEIGHT="200"></IFRAME>
<input type="hidden" name="S_Content" value="<%=Rs("SK_Content")%>"></td>
</tr>
<%
'自定义选项开始
set RsOptions=server.createobject("adodb.recordset")
sqlOptions="SELECT * from SK_SalesOptions where SK_Di=9 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=""12%"">"&RsOptions("SK_Title")&"</td><td class=""SK_Text1""><select name="&RsOptions("SK_FieldName")&">"
Set rsOptionsDetail=Server.CreateObject("ADODB.RecordSet") 
sqlOptionsDetail="SELECT * from SK_SalesOptionsDetail where SK_OptionsID="&RsOptions("FieldID")&"" 
rsOptionsDetail.Open sqlOptionsDetail,conn,1,1
Response.write"<option value="""" selected>--请选择--</option>"
do while not rsOptionsDetail.eof
selected=""
if rs(""&RsOptions("SK_FieldName")&"")=rsOptionsDetail("OptionsDetailID") then selected="selected='selected'"
Response.write"<option value="&rsOptionsDetail("OptionsDetailID")&" "&selected&">"&rsOptionsDetail("SK_OName")&"</option>"
rsOptionsDetail.movenext
loop
rsOptionsDetail.close
set rsOptionsDetail=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_SalesFields where SK_Di=9 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=""12%"">"&RsFields("SK_Title")&"</td><td class=""SK_Text1""><input type=""text"" size=""20"" name="&RsFields("SK_FieldName")&" value="&Rs(""&RsFields("SK_FieldName")&"")&"></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 type="hidden" name="ID" value="<%=rs("ItemContractID")%>">
<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>