<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_Client")="0" AND (Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK200000108"))) then Call ReturnError1()%>
<%
if F("ID")="" then Call ReturnError7()
if RQ("Action")="Mod" and F("ID")<>"" then

Bid=split(F("id"),",")
for i=0 to UBound(Bid)
set rs=server.createobject("adodb.recordset")
sql="select * from SK_ShareClient where SK_SalesID="&F("S_UserID")&" and SK_ClientID="&trim(Bid(i))
rs.open sql,conn,1,3
if not rs.eof or not rs.bof then
else
rs.AddNew
end if
rs("SK_ClientID")=Bid(i)
rs("SK_SalesID")=NoCSSHackInput(F("S_UserID"))
rs("SK_Time")=Now()
rs.Update
rs.Close 
set rs=Nothing

'Share begin
set rs1=server.createobject("adodb.recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql1="select * from SK_Client INNER JOIN SK_SystemUsers ON SK_Client.SK_SalesID=SK_SystemUsers.UsersID where SK_Client.SK_Del=0 and SK_Client.ClientID="&trim(Bid(i))
elseif Session("Manager")=3 then
sql1="select * from SK_Client INNER JOIN SK_SystemUsers ON SK_Client.SK_SalesID=SK_SystemUsers.UsersID where SK_Client.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_Client.ClientID="&trim(Bid(i))
elseif Session("Manager")=4 then
sql1="select * from SK_Client INNER JOIN SK_SystemUsers ON SK_Client.SK_SalesID=SK_SystemUsers.UsersID where SK_Client.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_Client.ClientID="&trim(Bid(i))
elseif Session("Manager")=5 then
sql1="select * from SK_Client INNER JOIN SK_SystemUsers ON SK_Client.SK_SalesID=SK_SystemUsers.UsersID where SK_Client.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&" and SK_Client.ClientID="&trim(Bid(i))
elseif Session("Manager")=6 then
sql1="select * from SK_Client INNER JOIN SK_SystemUsers ON SK_Client.SK_SalesID=SK_SystemUsers.UsersID where SK_Client.SK_Del=0 and SK_Client.SK_SalesID="&Session("UID")&" and SK_Client.ClientID="&trim(Bid(i))
end if
rs1.open sql1,Conn,1,3
if rs1("SK_Share")=0 then
rs1("SK_Share")=1
rs1.Update
rs1.close
set rs1=Nothing
end if
next
'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

Call Returnoktoback()
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>
function Form1_Validator(theForm)
{
if(form1.S_User.value ==""){
alert("对不起,请选择业务人员!");
form1.S_User.focus();
return false;
}

return true;
}
</SCRIPT>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x: hidden;
}
-->
</style>
</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 colspan="2" class="SK_Title1">选择业务人员</td>
</tr>

<tr>
<td width="23%" class="SK_Text2">共享给业务人员</td>
<td width="77%" class="SK_Text1"><input name="S_User" type="text" size="20" readonly> <a onClick="JavaScript:window.open('../System/SK.SSales.asp','SSales','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/SUser.gif" /></a>
<input name="S_UserID" type="hidden">
</td>
</tr>
<tr>
<td colspan="2" class="SK_Text">
<input type="hidden" name="id" value="<%=F("id")%>">
<INPUT class="button1" type="submit" value=" 保存 "> 
<input type="button" value=" 返回 " onClick="javascript:history.back();" 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>