PageRenderTime 35ms CodeModel.GetById 13ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/CRM/AccountEdit.asp

http://github.com/khaneh/Orders
ASP | 1021 lines | 929 code | 58 blank | 34 comment | 122 complexity | bdb863ac2b39d0ae38e928d4b43f1615 MD5 | raw file
   1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><% 
   2'CRM (1)
   3PageTitle= "������� ����"
   4if request("act")="getAccount" or  request("act")="submitcustomer" then
   5	SubmenuItem=2
   6	if not Auth(1 , 2) then NotAllowdToViewThisPage()
   7else
   8	SubmenuItem=3
   9	if not Auth(1 , 3) then NotAllowdToViewThisPage()
  10end if
  11
  12editFlag = 0
  13AccType = 2 
  14
  15%>
  16<!--#include file="top.asp" -->
  17<!--#include File="../include_farsiDateHandling.asp"-->
  18<!--#include File="../include_JS_InputMasks.asp"-->
  19
  20<style>
  21	.CustGenTable  { font-family:tahoma; font-size: 9pt;}
  22	.CustGenInput { font-family:tahoma; font-size: 9pt;}
  23</STYLE>
  24<SCRIPT LANGUAGE="JavaScript">
  25<!--
  26var okToProceed=false;
  27
  28var tempKeyBuffer;
  29function myKeyDownHandler(){
  30	tempKeyBuffer=window.event.keyCode;
  31}
  32function myKeyPressHandler(){
  33//	alert (tempKeyBuffer)
  34	if (tempKeyBuffer>=65 && tempKeyBuffer<=90){
  35		window.event.keyCode=tempKeyBuffer+32;
  36	}
  37	else if(tempKeyBuffer==186){
  38		window.event.keyCode=59;
  39	}
  40	else if(tempKeyBuffer==188){
  41		window.event.keyCode=44;
  42	}
  43	else if(tempKeyBuffer==190){
  44		window.event.keyCode=46;
  45	}
  46	else if(tempKeyBuffer==191){
  47		window.event.keyCode=47;
  48	}
  49	else if(tempKeyBuffer==192){
  50		window.event.keyCode=96;
  51	}
  52	else if(tempKeyBuffer>=219 && tempKeyBuffer<=221){
  53		window.event.keyCode=tempKeyBuffer-128;
  54	}
  55	else if(tempKeyBuffer==222){
  56		window.event.keyCode=39;
  57	}
  58}
  59//-->
  60</SCRIPT>
  61<font face="tahoma">
  62<!-- <div dir='rtl'><B>���� ����� </B>
  63</div> -->
  64<%
  65if request("act")="submitsearch" then
  66	if request("CustomerNameSearchBox") <> "" then
  67		SA_TitleOrName=request("CustomerNameSearchBox")
  68		mySQL="SELECT * FROM Accounts WHERE (REPLACE(AccountTitle, ' ', '') LIKE REPLACE(N'%"& SA_TitleOrName & "%', ' ', '') ) ORDER BY AccountTitle"
  69		Set RS1 = conn.Execute(mySQL)
  70
  71		if (RS1.eof) then 
  72					response.redirect "?errmsg=" & Server.URLEncode("���� ����� ���� ���.<br><a href='../CRM/AccountEdit.asp?act=getAccount'>���� ���Ͽ</a>")
  73
  74		' Not Found	%>
  75		<div dir='rtl'><B>���� ����� ���� ���</B> &nbsp; <A HREF="AccountEdit.asp" style='font-size:7pt;'>������ ����</A>
  76		</div><br>
  77	<%	else 
  78			SA_TitleOrName=request("CustomerNameSearchBox")
  79			SA_Action="return true;"
  80			SA_SearchAgainURL="AccountEdit.asp"
  81			SA_StepText="��� ��� : ������ ����"
  82%>
  83		<FORM METHOD=POST ACTION="AccountEdit.asp?act=editaccount">
  84			<!--#include File="../AR/include_SelectAccount.asp"-->
  85		</FORM>
  86<%
  87		end if
  88	end if
  89elseif request("act")="editaccount" AND (request("selectedCustomer") <> ""  or request("NextOf") <> "" or request("PrevOf") <> "") then 
  90
  91	'--------------------------------- START
  92	NextOf=request("NextOf")
  93	PrevOf=request("PrevOf")
  94	CusID=request("selectedCustomer")
  95	if NextOf <> "" AND isNumeric(NextOf) then
  96		NextOf=clng(NextOf)
  97		mySQL="SELECT TOP 1 AccountTitle FROM Accounts WHERE (ID = '"& NextOf & "')"
  98		set RS1=Conn.execute(mySQL)
  99		theTitle = RS1("AccountTitle")
 100
 101		'mySQL="SELECT TOP 1 ID FROM Accounts WHERE (AccountTitle > N'"& theTitle & "') OR ((ID > '"& NextOf & "') AND (AccountTitle = N'"& theTitle & "')) Order BY AccountTitle, ID"
 102
 103		'-------- changed by Alix (83-4-9) : be khaste mohaghegh tartibe hesaab haa az Alefbaa be Shomare Hesab tagheer kard
 104		mySQL="SELECT TOP 1 ID FROM Accounts WHERE (ID > '"& NextOf & "') Order BY ID"
 105
 106
 107		set RS1=Conn.execute(mySQL)
 108		if not Rs1.eof then
 109			CusID = RS1("ID")
 110			LinkToNext="<a href=""?act=show&NextOf="& CusID & """>���� &gt;</a>"
 111		else
 112			CusID = NextOf
 113			LinkToNext="���� �����"
 114		end if
 115		LinkToPrev="<a href=""?act=show&PrevOf="& CusID & """>&lt; ����</a>"
 116	elseif PrevOf <> "" AND isNumeric(PrevOf) then
 117		PrevOf = clng(PrevOf)
 118		mySQL="SELECT TOP 1 AccountTitle FROM Accounts WHERE (ID = '"& PrevOf & "')"
 119		set RS1=Conn.execute(mySQL)
 120		theTitle = RS1("AccountTitle")
 121
 122		'mySQL="SELECT TOP 1 ID FROM Accounts WHERE (AccountTitle < N'"& theTitle & "') OR ((ID < '"& PrevOf & "') AND (AccountTitle = N'"& theTitle & "')) Order BY AccountTitle DESC, ID DESC"
 123
 124		mySQL="SELECT TOP 1 ID FROM Accounts WHERE (ID < '"& PrevOf & "') Order BY ID DESC"
 125		set RS1=Conn.execute(mySQL)
 126		if not Rs1.eof then
 127			CusID = RS1("ID")
 128			LinkToPrev="<a href=""?act=show&PrevOf="& CusID & """>&lt; ����</a>"
 129		else
 130			CusID = PrevOf 
 131			LinkToPrev="���� �����"
 132		end if
 133		LinkToNext="<a href=""?act=show&NextOf="& CusID & """>���� &gt;</a>"
 134	elseif CusID <> "" AND isNumeric(CusID) then
 135		CusID=clng(CusID)
 136		LinkToNext="<a href=""?act=show&NextOf="& CusID & """>���� &gt;</a>"
 137		LinkToPrev="<a href=""?act=show&PrevOf="& CusID & """>&lt; ����</a>"
 138	else
 139		Conn.close
 140		response.redirect "?errmsg=" & Server.URLEncode("����� ���� ����� ����")
 141	end if
 142	'--------------------------------- END
 143	mySQL="SELECT * FROM Accounts WHERE (ID='"& CusID & "')"
 144	CustomerID=CusID
 145	Set RS1 = conn.Execute(mySQL)
 146	editFlag = 1
 147	ID				=	RS1("id")
 148	AccountTitle	=	RS1("AccountTitle")
 149	CreditLimit		=	RS1("CreditLimit")
 150	IsPersonal		=	RS1("IsPersonal")
 151	IsADefault		=	RS1("IsADefault")
 152	EconomicalCode	=	RS1("EconomicalCode")
 153	CSR				=	RS1("CSR")
 154	CompanyName		=	RS1("CompanyName")
 155	AccType			=	RS1("Type")
 156	Status			=	RS1("Status")
 157	Postable1		=	RS1("Postable1")
 158	Dear1			=	RS1("Dear1")
 159	FirstName1		=	RS1("FirstName1")
 160	LastName1		=	RS1("LastName1")
 161	City1			=	RS1("City1")
 162	Address1		=	RS1("Address1")
 163	Tel1			=	RS1("Tel1")
 164	Fax1			=	RS1("Fax1")
 165	Email1			=	RS1("Email1")
 166	Mobile1			=	RS1("Mobile1")
 167	PostCode1		=	RS1("PostCode1")
 168	Postable2		=	RS1("Postable2")
 169	Dear2			=	RS1("Dear2")
 170	FirstName2		=	RS1("FirstName2")
 171	LastName2		=	RS1("LastName2")
 172	City2			=	RS1("City2")
 173	Address2		=	RS1("Address2")
 174	Tel2			=	RS1("Tel2")
 175	Fax2			=	RS1("Fax2")
 176	Email2			=	RS1("Email2")
 177	Mobile2			=	RS1("Mobile2")
 178	PostCode2		=	RS1("PostCode2")
 179	NorRCode		=	RS1("NorRCode")
 180	employee		=	RS1("employee")
 181	JobTitle1		=	RS1("JobTitle1")
 182	JobTitle2		=	RS1("JobTitle2")
 183	website			=	RS1("website")
 184	maxCreditDay	=	RS1("maxCreditDay")
 185	maxChequeDay	=	RS1("maxChequeDay")
 186	maxChequeAmount	=	RS1("maxChequeAmount")
 187
 188end if
 189if request("act")="getAccount" or editFlag = 1 then
 190if CSR = "" then CSR = session("ID")
 191%>
 192<!-- ���� ������� �����  -->
 193		<FORM METHOD=POST ACTION="AccountEdit.asp?act=<% if editFlag = 0 then%>submitcustomer<%else%>submitEdit<%end if%>" onsubmit="if (document.all.AccountTitle.value=='') return false;">
 194		<br><br><INPUT TYPE="hidden" name=ID value=<%=ID%>>
 195		<table class="CustGenTable" Border="0" align='center' Width="600" Cellspacing="1" Cellpadding="5" Dir="RTL">
 196			<tr bgcolor='#C3C300'>
 197				<td align='center' colspan="6"><b>
 198				<% if editFlag = 0 then
 199					response.write "���� ������� ����  "& CusID
 200				   else
 201					response.write "������ ������� ����  "& CusID
 202				   end if %>
 203				</b></td>
 204			</tr>
 205			<tr>
 206				<td align='left' <% if not Auth(1,7) and editFlag=1 then response.write "title='��� ���� �� ������ ��� ���� ������!'"%>><span <% if Auth(1,7) or editFlag=0 then response.write "onclick='setAccountTitle();'" %>>����� ���� :</span></td>
 207				<td <% if not Auth(1,7) and editFlag=1 then response.write "title='��� ���� �� ������ ��� ���� ������!'"%>>
 208					<INPUT class="CustGenInput" TYPE="text" NAME="AccountTitle" VALUE="<%=AccountTitle%>" size="20" MaxLength="200" <%if Not Auth(1,7) and editFlag=1 then response.write "readonly"%>> 
 209					
 210				</td>
 211				<td align="left">���� ���� ���</td>
 212				<td align="right">
 213					<INPUT class="CustGenInput" TYPE="checkbox" NAME="IsPersonal" <% if IsPersonal then %> checked <% end if %> onclick='showCompanyName();'>
 214				</td>
 215				<td align="left">����:</td>
 216				<td align="right"> 
 217					<%if Auth(1 , 4) then %>
 218					<select name="CSR" class="CustGenInput" style="width:90">
 219						<option value=""> ������ ���� </option>
 220					<% set RSV=Conn.Execute ("SELECT * FROM Users ORDER BY RealName") ' WHERE Display=1 
 221					Do while not RSV.eof
 222					%>
 223						<option value="<%=RSV("ID")%>" <%
 224							if RSV("ID")=CSR then
 225								response.write " selected "
 226							end if
 227							%>><%=RSV("RealName")%></option>
 228					<%
 229					RSV.moveNext
 230					Loop
 231					RSV.close
 232					%>
 233
 234					</select> 
 235					<% else %>
 236<%
 237						set RSV=Conn.Execute ("SELECT * FROM Users WHERE Display=1 ORDER BY RealName") 
 238						Do while not RSV.eof
 239							if RSV("ID")=CSR then
 240								a = RSV("RealName")
 241							end if
 242						RSV.moveNext
 243						Loop
 244						RSV.close					
 245%> 						
 246						<INPUT TYPE="text" NAME="" value="<%=a%>" size=9 readonly>
 247						<INPUT TYPE="hidden" NAME="CSR" value="<%=CSR%>" size=9 readonly>
 248					<% end if %>
 249				</td >
 250			</tr>
 251			<tr>
 252				<td align='left'>��� ���� : </td>
 253				<td align="right">
 254					<INPUT class="CustGenInput" TYPE="text"  <% if IsPersonal then %> style="visibility:hidden;" <% end if %>NAME="CompanyName" value="<%=CompanyName%>" size="20">
 255				</td>
 256				<td align="left">���:</td>
 257				<td align='right'>
 258					<select name="type" class="CustGenInput">
 259					<%
 260					set rs=Conn.Execute("select * from accountTypes")
 261					while not rs.eof
 262						response.write "<option " 
 263						if CInt(AccType) = cint(rs("id")) then response.write " selected " 
 264						response.write " value='" & rs("id") & "'>" & rs("name") & "</option>" 
 265						rs.moveNext
 266					wend
 267					rs.close
 268%> 
 269					</select>
 270				</td>
 271				<td align='left'>�����:</td>
 272				<td align="right">
 273<%				if editFlag=0 then Status=1
 274				if Auth(1,5) then%>	
 275					<select name="Status" class="CustGenInput">
 276					<option <% if Status = 1 then response.write "selected" %> value=1>����
 277					<option <% if Status = 2 then response.write "selected" %> value=2>�����
 278					<option <% if Status = 3 then response.write "selected" %> value=3>�����
 279					</select>
 280				<%else
 281					select case Status
 282						Case 1: StatusText = "����"
 283						Case 2: StatusText = "�����"
 284						Case 3: StatusText = "�����"
 285					end select
 286%>					<INPUT class="CustGenInput" TYPE="text" name="StatusText" value="<%=StatusText%>" size=12 readonly>
 287					<INPUT TYPE="Hidden" name="Status" value="<%=Status%>">
 288				<%end if%>
 289				</td>
 290			</tr>
 291			<tr>
 292				<td align="left">
 293					<input name="lblNorRCode" type="text" readonly value="<%If IsPersonal Then %> ����� ���: <%Else%> ����� ���: <%End if%>" size=10 style='background-color:transparent;border:0 transparent hidden;text-align:left;'>
 294				</td>
 295				<td align="right">
 296					<input class="CustGenInput" name="NorRCode" dir="ltr" value="<%=NorRCode%>" type="text" size="15" maxlength="20">
 297				</td>
 298				<td align="left">�� ������� : </td>
 299				<td align='right'>
 300					<INPUT class="CustGenInput" NAME="EconomicalCode" dir="ltr" value="<%=EconomicalCode%>" TYPE="text" size="10" maxlength="20" style="direction:LTR;"> 
 301				</td>
 302				<td align="left">��� ��� ���</td>
 303				<td align='right'>
 304					<INPUT class="CustGenInput" TYPE="checkbox" NAME="IsADefault" <% if IsADefault or editFlag<>1 then response.write "checked" %>>				
 305				</td>
 306			</tr>
 307			<tr>
 308				<td align='left'>��� ������: </td>
 309				<td>
 310					<INPUT dir=LTR class="CustGenInput num" TYPE="text" name="CreditLimit" value="<%=separate(CreditLimit)%>" size="12" maxlength="15" <%if not Auth(1 , 4) then response.write "readonly" %>> ����
 311				</td>
 312				<td align='right'>����� ��� ������: </td>
 313				<td>
 314					<input dir="ltr" lass="CustGenInput" TYPE="text" name="maxCreditDay" value="<%=separate(maxCreditDay)%>" size=3 <%if not Auth(1 , 4) then response.write "readonly" %>/>
 315				</td>
 316				<td align="left">����� �����:</td>
 317				<td align="right">
 318					<select name="employee" id="employee" <% if IsPersonal then response.write " style='visibility:hidden;' " %> >
 319						<option value="0" <%if IsNull(employee) or employee=0 or IsPersonal then response.write " selected='selected' "%>>������ ����</option>
 320						<option value="1" <%if employee=1 then response.write " selected='selected' "%>>0 �� 5 ���</option>
 321						<option value="2" <%if employee=2 then response.write " selected='selected' "%>>6 �� 20 ���</option>
 322						<option value="3" <%if employee=3 then response.write " selected='selected' "%>>21 �� 100 ���</option>
 323						<option value="4" <%if employee=4 then response.write " selected='selected' "%>>101 �� ����</option>
 324					</select>
 325				</td>
 326			</tr>
 327			<tr>
 328				<td align="left">��� ������ ����� ��:</td>
 329				<td>
 330					<input name="maxChequeAmount" class="num" type="text" value="<%=separate(maxChequeAmount)%>" size="10" <%if not Auth(1 , 4) then response.write "readonly" %>/>
 331				</td>
 332				<td align="left">��� ������ ��� ��:</td>
 333				<td align=right>
 334					<input name="maxChequeDay" class="num" type="text" value="<%=separate(maxChequeDay)%>" size="10" <%if not Auth(1 , 4) then response.write "readonly" %>/>
 335				</td>
 336				<td align="left">�� ����:</td>
 337				<td align=right>
 338					<input class="CustGenInput" name="website" dir="ltr" value="<%=website%>" type="text" size="20" maxlength="100">
 339				</td>
 340			</tr>
 341			<tr bgcolor='#C3C300'>
 342				<td align='center' colspan='5'><b> ������� ���� ���� </b></td>
 343				<td align='center'>
 344				<INPUT TYPE="checkbox" NAME="postable1" <% if postable1 then response.write "checked" %> >
 345				���� ��� ���� </td>
 346			</tr>
 347			<tr>
 348				<td align='center'>
 349					<BR>
 350					<SELECT class="CustGenInput" NAME="Dear1" style="width:70">
 351						<option value="">������ ����</option>
 352						<option <% if Dear1="����" then%> selected <% end if %>value="����">����</option>
 353						<option <% if Dear1="����" then%> selected <% end if %> value="����">����</option>
 354					</SELECT>
 355				</td>
 356				<td colspan="3" align='center'>
 357					<BR>
 358					<span>���</span> 
 359					<INPUT class="CustGenInput" NAME="FirstName1" value="<%=FirstName1%>" TYPE="text" size="13">
 360					<span>�����</span>
 361					<INPUT class="CustGenInput" NAME="LastName1" value="<%=LastName1%>" TYPE="text" size="13">
 362				</td>				
 363				<td align='center'>
 364					<span>��� </span>
 365					<BR>
 366					<INPUT class="CustGenInput" TYPE="text" NAME="City1" size="15" value="<%=City1%>">
 367				</td>
 368				<td align='center'>
 369					<span>�� </span>
 370					<BR>
 371					<INPUT class="CustGenInput" TYPE="text" NAME="PostCode1" size="15" value="<%=PostCode1%>">
 372				</td>
 373			</tr>
 374			<tr>
 375				<td align='center' rowspan='3' colspan='4'>
 376					<span> ����</span> 
 377					<BR><br>
 378					<TEXTAREA class="CustGenInput" NAME="Address1" ROWS="6" COLS="60"><%=Address1%></TEXTAREA>
 379				</td>
 380				<td valign='top' align='center'>
 381					<span>����</span>
 382					<BR>
 383					<INPUT class="CustGenInput" Dir="LTR" NAME="Tel1" value="<%=Tel1%>" TYPE="text" size="15">
 384				</td>
 385				<td valign='top' align='center'>
 386					<span>����</span>
 387					<BR>
 388					<INPUT class="CustGenInput" Dir="LTR" NAME="Fax1" value="<%=Fax1%>" TYPE="text" size="15">
 389				</td>
 390			</tr>
 391			<tr>
 392				<td align='center'>
 393					<span>������ </span>
 394					<BR>
 395					<INPUT class="CustGenInput" TYPE="text"  Dir="LTR"  NAME="Mobile1" size="15" value="<%=Mobile1%>">
 396				</td>
 397				<td valign='top' align='center'>
 398					<span>�����</span>
 399					<BR>
 400					<INPUT class="CustGenInput" Dir="LTR" NAME="Email1"  value="<%=Email1%>" TYPE="text" size="15" onkeyDown="return myKeyDownHandler();" onKeyPress="return myKeyPressHandler();">
 401				</td>
 402			</tr>
 403			<tr>
 404				<td colspan="2" align="center">
 405					<span>��� </span>
 406					<br>
 407					<input class="CustGenInput" type="text" dir="rtl" name="JobTitle1" value="<%=JobTitle1%>" size="40">
 408				</td>
 409			</tr>
 410			<tr bgcolor='#C3C300'>
 411				<td align='center' colspan='5'><b> ������� ���� ��� </b></td>
 412				<td align='center'>
 413				<INPUT TYPE="checkbox" NAME="postable2" <% if postable2 then response.write "checked" %> >
 414				���� ��� ���� </td>
 415			</tr>
 416			<tr>
 417				<td align='center'>
 418					<BR>
 419					<SELECT class="CustGenInput" NAME="Dear2" style="width:70">
 420						<option value="">������ ����</option>
 421						<option <% if Dear2="����" then%> selected <% end if %>value="����">����</option>
 422						<option <% if Dear2="����" then%> selected <% end if %> value="����">����</option>
 423					</SELECT>
 424				</td>
 425				<td colspan=3 align='center'>
 426					<BR>
 427					<span>��� </span>
 428					<INPUT class="CustGenInput" NAME="FirstName2" value="<%=FirstName2%>" TYPE="text" size="13">
 429					<span>�����</span>
 430					<INPUT class="CustGenInput" NAME="LastName2" value="<%=LastName2%>" TYPE="text" size="13">
 431				</td>
 432				<td align='center'>
 433					<span>��� </span>
 434					<BR>
 435					<INPUT class="CustGenInput" TYPE="text" NAME="City2" size="15" value="<%=City2%>">
 436				</td>
 437				<td align='center'>
 438					<span>�� </span>
 439					<BR>
 440					<INPUT class="CustGenInput" TYPE="text" NAME="PostCode2" size="15" value="<%=PostCode2%>">
 441				</td>
 442			</tr>
 443			<tr>
 444				<td align='center' rowspan='3' colspan='4'>
 445					<span> ���� </span>
 446					<BR>
 447					<TEXTAREA class="CustGenInput" NAME="Address2" ROWS="6" COLS="60"><%=Address2%></TEXTAREA>
 448				</td>
 449				<td valign='top' align='center'>
 450					<span>����</span>
 451					<BR>
 452					<INPUT class="CustGenInput" Dir="LTR" NAME="Tel2" value="<%=Tel2%>" TYPE="text" size="15">
 453				</td>
 454				<td valign='top' align='center'>
 455					<span>����</span>
 456					<BR>
 457					<INPUT class="CustGenInput" Dir="LTR" NAME="Fax2" value="<%=Fax2%>" TYPE="text" size="15">
 458				</td>
 459			</tr>
 460			<tr>
 461				<td align='center'>
 462					<span>������ </span>
 463					<BR>
 464					<INPUT class="CustGenInput" TYPE="text"  Dir="LTR"  NAME="Mobile2" size="15" value="<%=Mobile2%>">
 465				</td>
 466				<td valign='top' align='center'>
 467					<span>�����</span>
 468					<BR>
 469					<INPUT class="CustGenInput" Dir="LTR" NAME="Email2"  value="<%=Email2%>" TYPE="text" size="15" onkeyDown="return myKeyDownHandler();" onKeyPress="return myKeyPressHandler();">
 470				</td>
 471			</tr>
 472			<tr>
 473				<td colspan="2" align="center">
 474					<span>��� </span>
 475					<br>
 476					<input class="CustGenInput" type="text" dir="rtl" name="JobTitle2" value="<%=JobTitle2%>" size="40">
 477				</td>
 478			</tr>
 479			<%' ----------------------------S A M    E D I T  ----------------------------------------
 480			%>
 481			<tr bgcolor='#C3C300'>
 482				<td align='center' colspan='6'><b>���� ����</b></td>
 483			</tr>
 484			<tr>
 485				<td colspan=6>
 486					<table>
 487			<%
 488			accountGroup=0
 489			IF CusID <>"" then 
 490				mySQL="select * from accountGroupRelations where account="&CusID
 491				set RSV=conn.Execute(mySQL)
 492				if not RSV.eof then accountGroup=RSV("AccountGroup")
 493				RSV.close
 494				set RSV=nothing
 495			end if
 496			
 497			col=0
 498			oldState="True"
 499			set RSV=Conn.Execute ("SELECT * FROM accountGroups ORDER BY isPartner DESC, Name") 
 500			Do while not RSV.eof
 501				if (RSV("isPartner")<>oldState) then 
 502					if col <> 0 then 
 503						col = 0
 504						response.write "</tr>"
 505					end if
 506				end if
 507				if (col = 0) then response.write "<tr>"
 508				col=col+1
 509				%>
 510				<td <%
 511				if RSV("isPartner")="True" then response.write "bgcolor='#C33300'"%> >
 512					<INPUT type='radio' name='accountGroup' 
 513						<% if RSV("ID")=accountGroup then response.write(" CHECKED ")%> 
 514						value='<%=RSV("ID")%>'>
 515					<%=RSV("name")%>
 516				</td>
 517				<%
 518				if col=4 then 
 519					response.write "</tr>"
 520					col=0
 521				end if
 522				oldState = RSV("isPartner")
 523			RSV.moveNext
 524			Loop
 525			RSV.close
 526			set RSV=nothing
 527			%>
 528					</table>
 529				</td>
 530			</tr>
 531			<tr bgcolor='#C3C300'>
 532				<td align='center' colspan='6'><b>������</b></td>
 533			</tr>
 534			<tr>
 535				<td colspan="6">
 536					<table>
 537						<%
 538						if CLng(CusID)>0 then 
 539							set rs=Conn.Execute("select * from accountGroupRelations where account=" & CusID)
 540							if rs.eof then 
 541							%>
 542							<tr>
 543								<td><b>������! ������ ��� �� ����� ����� ���� ����� �� �� ���� ���� �� �� ������ ���� �����</b></td>
 544							</tr>
 545							<%						
 546							else
 547								group=rs("accountGroup")
 548								rs.close
 549								set rs=Conn.Execute("select * from account_questions where [group]=" & group)
 550								if rs.eof then
 551								%>
 552								<tr>
 553									<td><b>���� ��� ���� ��� ����� �����</b></td>
 554								</tr>
 555								<%
 556								else
 557									while not rs.eof
 558										%>
 559								<tr>
 560									<td><%=rs("name")%><input name="questionID" type="hidden" value="<%=rs("id")%>"></td>
 561									<td>
 562										<%
 563										'response.write ("select * from account_answers where account_id=" & CusID & " and question=" & rs("id"))
 564										set rss=Conn.Execute("select * from account_answers where account_id=" & CusID & " and question=" & rs("id"))
 565										if CInt(rs("type"))=0 then
 566										%>
 567										<input name="answer" type="text" <%if not rss.eof then response.write (" value='" & rss("answer") & "'")%>>
 568										<%
 569										elseif CInt(rs("type"))=1 then
 570										%>
 571										<select name="answer">
 572										<%
 573											choice=Split(rs("choice"),",")
 574											for i=0 to UBound(choice)
 575											%>
 576											<option value="<%=trim(choice(i))%>" <%if not rss.eof then if rss("answer")=choice(i) then response.write(" selected ")%>><%=choice(i)%></option>
 577											<%
 578											next
 579										%>
 580										</select>
 581										<%
 582										end if
 583										rss.close
 584										%>
 585									</td>
 586								</tr>
 587										<%
 588										rs.moveNext
 589									wend
 590									rs.close
 591								end if
 592							end if
 593						end if
 594						%>
 595					</table>
 596				</td>
 597			</tr>
 598			<%' ----------------------------S A M    E D I T  ----------------------------------------
 599			%>
 600			<tr bgcolor='#C3C300'>
 601				<td align='center' colspan="6">
 602					<INPUT class="CustGenInput" TYPE="submit"  NAME="submit" value="���"> 
 603					<% if request("act")="editaccount" then %>
 604					<INPUT class="CustGenInput" TYPE="submit" NAME="submit" value="��� � ����">
 605					<% end if %>
 606				</td>
 607			</tr>
 608			<tr>
 609				<td colspan="6">&nbsp;</td>
 610			</tr>
 611			<tr bgcolor='#C3C300'>
 612				<td align='center' colspan="6"><b>������� �����</b></td>
 613			</tr>
 614			<tr dir="LTR">
 615				<td align='center' colspan="6">
 616			<% OLD_ACID = ID%>
 617			<!--#include File="include_OldCusData.asp"-->
 618				</td>
 619			</tr>
 620		</table>
 621		</FORM>
 622		<SCRIPT LANGUAGE="JavaScript">
 623		<!--
 624			//document.all.Name.focus();
 625		//-->
 626		</SCRIPT>
 627<%
 628elseif request("act")="submitEdit" then 
 629	EditDate		= shamsiToday()
 630	EditBy			= session("ID")
 631	ID				= sqlSafe(Request.form("id"))
 632
 633	AccountTitle	= left(sqlSafe(Request.form("AccountTitle")) , 200) ' Field width is 200
 634	IsPersonal		= sqlSafe(Request.form("IsPersonal"))
 635	IsADefault		= sqlSafe(Request.form("IsADefault"))
 636	EconomicalCode	= left(sqlSafe(Request.form("EconomicalCode")) , 20)
 637	CompanyName		= left(sqlSafe(Request.form("CompanyName")) , 50)
 638	NorRCode		= Left(sqlSafe(Request.Form("NorRCode")) , 20)
 639
 640	Postable1		= sqlSafe(Request.form("Postable1"))
 641	Dear1			= left(sqlSafe(Request.form("Dear1")) , 20)
 642	FirstName1		= left(sqlSafe(Request.form("FirstName1")) , 50)
 643	LastName1		= left(sqlSafe(Request.form("LastName1")) , 50)
 644	JobTitle1		= left(sqlSafe(Request.form("JobTitle1")) , 50)
 645	Tel1			= left(sqlSafe(Request.form("Tel1")) , 50)
 646	Mobile1			= left(sqlSafe(Request.form("Mobile1")) , 50)
 647	Fax1			= left(sqlSafe(Request.form("Fax1")) , 50)
 648	Email1			= left(sqlSafe(Request.form("Email1")) , 50)
 649	City1			= left(sqlSafe(Request.form("City1")) , 50)
 650	Address1		= left(sqlSafe(Request.form("Address1")) , 255)
 651	PostCode1		= left(sqlSafe(Request.form("PostCode1")) , 50)
 652
 653	Postable2		= sqlSafe(Request.form("Postable2"))
 654	Dear2			= left(sqlSafe(Request.form("Dear2")) , 20)
 655	FirstName2		= left(sqlSafe(Request.form("FirstName2")) , 50)
 656	LastName2		= left(sqlSafe(Request.form("LastName2")) , 50)
 657	JobTitle2		= left(sqlSafe(Request.form("JobTitle2")) , 50)
 658	Tel2			= left(sqlSafe(Request.form("Tel2")) , 50)
 659	Mobile2			= left(sqlSafe(Request.form("Mobile2")) , 50)
 660	Fax2			= left(sqlSafe(Request.form("Fax2")) , 50)
 661	Email2			= left(sqlSafe(Request.form("Email2")) , 50)
 662	City2			= left(sqlSafe(Request.form("City2")) , 50)
 663	Address2		= left(sqlSafe(Request.form("Address2")) , 255)
 664	PostCode2		= left(sqlSafe(Request.form("PostCode2")) , 50)
 665
 666	CreditLimit		= cdbl(text2value(Request.form("CreditLimit")))
 667	accountGroup	= cdbl(text2value(request.form("accountGroup")))
 668	employee		= cint(text2value(request.form("employee")))
 669	website			= left(sqlSafe(Request.form("website")) , 100)
 670	maxCreditDay	= cdbl(text2value(Request.form("maxCreditDay")))
 671	maxChequeDay	= cdbl(text2value(Request.form("maxChequeDay")))
 672	maxChequeAmount	= cdbl(text2value(Request.form("maxChequeAmount")))
 673	
 674	if not Auth(1 , 4) then ' Doesn't have the permission to set CSR / credit limit
 675		CSR			= ""
 676	else
 677		CSR			= cint(sqlSafe(Request.form("CSR")))
 678
 679		mySQL="SELECT RealName FROM Users WHERE (ID = "& CSR & ")"
 680		Set RS1=Conn.Execute(mySQL)
 681		if RS1.eof then
 682			Conn.close
 683			response.redirect "?msg=" & Server.URLEncode("���� ������ ���� ���.")
 684		else
 685			NewCSRName=		RS1("RealName")
 686		end if
 687		RS1.close
 688
 689		mySQL="SELECT Accounts.CSR, Users.RealName, Accounts.CreditLimit, Accounts.maxCreditDay, Accounts.maxChequeDay, Accounts.maxChequeAmount FROM Accounts INNER JOIN Users ON Accounts.CSR = Users.ID WHERE (Accounts.ID = "& ID & ")"
 690		Set RS1=Conn.Execute(mySQL)
 691		if RS1.eof then
 692			Conn.close
 693			response.redirect "?msg=" & Server.URLEncode("���� ������� ���� ���.")
 694		else
 695			OldCreditLimit=	cdbl(RS1("CreditLimit"))
 696			oldMaxCreditDay = CDbl(rs1("maxCreditDay"))
 697			oldMaxChequeDay = CDbl(rs1("maxChequeDay"))
 698			oldMaxChequeAmount = CDbl(rs1("maxChequeAmount"))
 699			OldCSRID=		cint(RS1("CSR"))
 700			OldCSRName=		RS1("RealName")
 701		end if
 702		RS1.close
 703		Set RS1=Nothing
 704
 705		if OldCSRID <> CSR OR OldCreditLimit <> CreditLimit or maxChequeDay<>oldMaxChequeDay or oldMaxCreditDay<>maxCreditDay or oldMaxChequeAmount<>maxChequeAmount then
 706
 707			mySQL = "SELECT [User] as ID, OnAccountCSRChangeSendMessageTo FROM UserDefaults WHERE (([User] = "& session("ID") & ") OR (UserDefaults.[User] = 0)) AND (OnAccountCSRChangeSendMessageTo IS NOT NULL) ORDER BY ABS(UserDefaults.[User]) DESC"
 708			Set RS2 = Conn.Execute (mySQL)
 709
 710			MessageTo=RS2("OnAccountCSRChangeSendMessageTo")
 711			RS2.close
 712			Set RS2 = Nothing
 713
 714			msg = "" '"���� " & session("CSRName") & " "
 715			tmpAnd = ""
 716			if OldCSRID <> CSR then
 717				msg= "����� ������ �� '" & OldCSRName & "' �� '" & NewCSRName & "' "
 718				tmpAnd = "� "
 719			end if
 720
 721			if OldCreditLimit <> CreditLimit then
 722				msg = msg & tmpAnd &  "��� ������ ��  '" & Separate(OldCreditLimit) & "' �� '" & Separate(CreditLimit) & "' "
 723				tmpAnd = "� "
 724			end if
 725			if maxCreditDay<>oldMaxCreditDay then 
 726				msg = msg & tmpAnd & "��� ������ �� " & Separate(oldMaxCreditDay) & " ��� �� " & Separate(maxCreditDay) & " ��� "
 727				tmpAnd = "� "
 728			end if
 729			if maxChequeAmount<>oldMaxChequeAmount then 
 730				msg = msg & tmpAnd & "������ ���� �� �� " & Separate(oldMaxChequeAmount) & " �� " & Separate(maxChequeAmount) & " "
 731				tmpAnd = "� "
 732			end if
 733			if maxChequeDay<>oldMaxChequeDay then 
 734				msg = msg & tmpAnd & "������ ����� �� �� " & Separate(oldMaxChequeDay) & " ��� �� " & Separate(maxChequeDay) & " ��� "
 735				tmpAnd = "� "
 736			end if
 737			msg = msg & "����� ����."
 738			
 739			MsgTo			=	MessageTo
 740			msgTitle		=	"Account changed"
 741			msgBody			=	sqlSafe(msg)
 742			RelatedTable	=	"accounts"
 743			relatedID		=	ID
 744			replyTo			=	0
 745			IsReply			=	0
 746			urgent			=	1
 747			MsgFrom			=	session("ID")
 748			MsgDate			=	shamsiToday()
 749			MsgTime			=	currentTime10()
 750			mySQL="INSERT INTO Messages (MsgFrom, MsgTo, MsgTime, MsgDate, IsRead, MsgTitle, MsgBody, replyTo, IsReply, relatedID, RelatedTable, urgent) VALUES ( "& MsgFrom & ", "& MsgTo & ", N'"& MsgTime & "', N'"& MsgDate & "', 0, N'"& MsgTitle & "', N'"& MsgBody & "', "& replyTo & ", "& IsReply & ", "& relatedID & ", '"& RelatedTable & "', "& urgent & ")"
 751			Conn.Execute (mySQL)
 752
 753		end if
 754
 755	end if
 756
 757	AccType			= sqlSafe(Request.form("Type"))
 758	Status			= sqlSafe(Request.form("Status"))
 759	'ACCID			= sqlSafe(Request.form("ACCID"))
 760	' ----------------------------S A M    E D I T  ----------------------------------------
 761	mySQL="select * from AccountGroupRelations where account="&id 
 762	set rs1= Conn.Execute(mySQL)
 763	if rs1.eof then 
 764		oldAccountGroup=0
 765	else 
 766		oldAccountGroup=rs1("AccountGroup")
 767	end if
 768	rs1.close
 769	set rs1=nothing
 770	' ----------------------------S A M    E D I T  ----------------------------------------
 771	if IsPersonal="on" then
 772		IsPersonal=1
 773		CompanyName=""
 774	else 
 775		IsPersonal=0
 776	end if
 777
 778	if IsADefault="on" then
 779		IsADefault=1
 780	else 
 781		IsADefault=0
 782	end if
 783
 784	if Postable1="on" then
 785		Postable1=1
 786	else 
 787		Postable1=0
 788	end if
 789
 790	if Postable2="on" then
 791		Postable2=1
 792	else 
 793		Postable2=0
 794	end if
 795
 796'	Added By kid 820727 
 797'	-------------------------------
 798'	Log The Edition Before Updating
 799
 800	conn.Execute("INSERT INTO AccountsEditLog SELECT '"& EditDate & "' AS EditedOn, '"& EditBy & "' AS EditedBy, * FROM Accounts WHERE (ID = "& ID & ")")
 801
 802'	End of Log
 803'   -------------------------------
 804	if CSR="" then
 805		mySQL="UPDATE Accounts SET LastEditOn='"& EditDate & "', LastEditBy='"& EditBy& "', Type ="&AccType & ", Status ="&Status & ", AccountTitle =N'"& AccountTitle& "', Postable1 = "& Postable1 & ", Postable2 = "& Postable2 & ", IsADefault = "& IsADefault & ", EconomicalCode =N'"& EconomicalCode& "', IsPersonal ="& IsPersonal& ", CompanyName =N'"& CompanyName& "', Dear1 =N'"& Dear1& "', FirstName1 =N'"& FirstName1& "', LastName1 =N'"& LastName1& "', JobTitle1 =N'"& JobTitle1& "', Tel1 =N'"& Tel1& "', Fax1 =N'"& Fax1& "', EMail1 =N'"& EMail1& "', Mobile1 =N'"& Mobile1& "', PostCode1 =N'"& PostCode1& "', City1 =N'"& City1& "', Address1 =N'"& Address1& "', Dear2 =N'"& Dear2& "', FirstName2 =N'"& FirstName2& "', LastName2 =N'"& LastName2& "', JobTitle2 =N'"& JobTitle2 & "', Tel2 =N'"& Tel2& "', Fax2 =N'"& Fax2& "', EMail2 =N'"& EMail2& "', Mobile2 =N'"& Mobile2& "', PostCode2 =N'"& PostCode2& "', City2 =N'"& City2& "', Address2 =N'"& Address2& "', NorRCode = N'" & NorRCode & "' , employee=" & employee & ",website=N'" & website & "' WHERE (ID = "& ID & ")"
 806	else
 807		mySQL="UPDATE Accounts SET CSR ="& CSR & ", LastEditOn='"& EditDate & "', LastEditBy='"& EditBy& "', Type ="&AccType & ", Status ="&Status & ", AccountTitle =N'"& AccountTitle& "', Postable1 = "& Postable1 & ", Postable2 = "& Postable2 & ", IsADefault = "& IsADefault & ", EconomicalCode =N'"& EconomicalCode& "', CreditLimit="& CreditLimit & ", IsPersonal ="& IsPersonal& ", CompanyName =N'"& CompanyName& "', Dear1 =N'"& Dear1& "', FirstName1 =N'"& FirstName1& "', LastName1 =N'"& LastName1& "', JobTitle1 =N'"& JobTitle1& "', Tel1 =N'"& Tel1& "', Fax1 =N'"& Fax1& "', EMail1 =N'"& EMail1& "', Mobile1 =N'"& Mobile1& "', PostCode1 =N'"& PostCode1& "', City1 =N'"& City1& "', Address1 =N'"& Address1& "', Dear2 =N'"& Dear2& "', FirstName2 =N'"& FirstName2& "', LastName2 =N'"& LastName2& "', JobTitle2 =N'"& JobTitle2 & "', Tel2 =N'"& Tel2& "', Fax2 =N'"& Fax2& "', EMail2 =N'"& EMail2& "', Mobile2 =N'"& Mobile2& "', PostCode2 =N'"& PostCode2& "', City2 =N'"& City2& "', Address2 =N'"& Address2& "', NorRCode = N'" & NorRCode & "',employee=" & employee & ",website=N'" & website & "',maxCreditDay = " & maxCreditDay & ",maxChequeDay=" & maxChequeDay & ", maxChequeAmount=" & maxChequeAmount & "  WHERE (ID = "& ID & ")"
 808	end If
 809	'response.write mySQL
 810	'response.end
 811	conn.Execute(mySQL)
 812	' ----------------------------S A M    E D I T  ----------------------------------------
 813'	response.write oldAccountGroup&"<br>"&accountGroup&"<br>"&id&"<br>"
 814	if oldAccountGroup<>accountGroup then
 815		conn.Execute("DELETE FROM AccountGroupRelations where account="&id&" AND AccountGroup="&oldAccountGroup)
 816		conn.Execute("INSERT INTO AccountGroupRelations (Account,AccountGroup) VALUES ("&id&","&accountGroup&")") 
 817	end if
 818	questionID=split(request.form("questionID"),",")
 819	'response.write (request.form("questionID"))
 820	answers=split(request("answer"), ",")
 821	set rs=Conn.Execute("select account_answers.* from account_answers inner join account_questions on account_questions.id=account_answers.question where account_questions.[group]=" & accountGroup & " and account_answers.account_id=" & id)
 822	while not rs.eof
 823		answer=""
 824		for i=0 to UBound(questionID)
 825			if cint(rs("id"))=cint(questionID(i)) then answer=trim(answers(i))
 826			'response.write rs("id") &","&questionID(i)&","& answers(i)&"<br>"
 827			'response.write answer
 828		next 
 829		'response.end
 830		Conn.Execute("update account_answers set answer=N'" & answer & "' where id=" & rs("id"))
 831		'response.write("update account_answers set answer=N'" & answer & "' where id=" & rs("id") &"<br>")
 832		rs.moveNext
 833	wend
 834	
 835	'response.end
 836	rs.close
 837	set rs=Conn.Execute("select * from account_questions where [group]=" & accountGroup & " and id not in (select question from account_answers where account_id=" & id & ")")
 838	while not rs.eof
 839		answer=""
 840		'response.w
 841		for i=0 to UBound(questionID)
 842			if cint(rs("id"))=cint(questionID(i)) then answer=trim(answers(i))
 843		next 
 844		Conn.Execute("insert into account_answers (question,answer,account_id) values (" & rs("id") & ",N'" & answer & "'," & id & ")")
 845		rs.moveNext
 846	wend
 847	rs.close
 848	' ----------------------------S A M    E D I T  ----------------------------------------
 849	if request("submit")="��� � ����" then 
 850		response.redirect "AccountEdit.asp?act=editaccount&NextOf=" & ID & "&msg=" & Server.URLEncode("������� ����  ���� �� ��� ��.")
 851	else
 852		response.redirect "AccountInfo.asp?act=show&selectedCustomer=" & ID & "&msg=" & Server.URLEncode("������� ���� �� ��� ��.")
 853	end if
 854
 855elseif request("act")="submitcustomer" then 
 856	CreatedDate		=	shamsiToday()
 857	CreatedBy		=	session("ID")
 858
 859	AccountTitle	= left(sqlSafe(Request.form("AccountTitle")) , 200) ' Field width is 200
 860	CreditLimit		= text2value(Request.form("CreditLimit"))
 861	IsPersonal		= sqlSafe(Request.form("IsPersonal"))
 862	IsADefault		= sqlSafe(Request.form("IsADefault"))
 863	EconomicalCode	= left(sqlSafe(Request.form("EconomicalCode")) , 20)
 864	CompanyName		= left(sqlSafe(Request.form("CompanyName")) , 50)
 865	NorRCode		= Left(sqlSafe(Request.Form("NorRCode")) , 20)
 866
 867	Postable1		= sqlSafe(Request.form("Postable1"))
 868	Dear1			= left(sqlSafe(Request.form("Dear1")) , 20)
 869	FirstName1		= left(sqlSafe(Request.form("FirstName1")) , 50)
 870	LastName1		= left(sqlSafe(Request.form("LastName1")) , 50)
 871	JobTitle1		= left(sqlSafe(Request.form("JobTitle1")) , 50)
 872	Tel1			= left(sqlSafe(Request.form("Tel1")) , 50)
 873	Mobile1			= left(sqlSafe(Request.form("Mobile1")) , 50)
 874	Fax1			= left(sqlSafe(Request.form("Fax1")) , 50)
 875	Email1			= left(sqlSafe(Request.form("Email1")) , 50)
 876	City1			= left(sqlSafe(Request.form("City1")) , 50)
 877	Address1		= left(sqlSafe(Request.form("Address1")) , 255)
 878	PostCode1		= left(sqlSafe(Request.form("PostCode1")) , 50)
 879
 880	Postable2		= sqlSafe(Request.form("Postable2"))
 881	Dear2			= left(sqlSafe(Request.form("Dear2")) , 20)
 882	FirstName2		= left(sqlSafe(Request.form("FirstName2")) , 50)
 883	LastName2		= left(sqlSafe(Request.form("LastName2")) , 50)
 884	JobTitle2		= left(sqlSafe(Request.form("JobTitle2")) , 50)
 885	Tel2			= left(sqlSafe(Request.form("Tel2")) , 50)
 886	Mobile2			= left(sqlSafe(Request.form("Mobile2")) , 50)
 887	Fax2			= left(sqlSafe(Request.form("Fax2")) , 50)
 888	Email2			= left(sqlSafe(Request.form("Email2")) , 50)
 889	City2			= left(sqlSafe(Request.form("City2")) , 50)
 890	Address2		= left(sqlSafe(Request.form("Address2")) , 255)
 891	PostCode2		= left(sqlSafe(Request.form("PostCode2")) , 50)
 892
 893	CreditLimit		= cdbl(text2value(Request.form("CreditLimit")))
 894	accountGroup	= cdbl(text2value(request.form("accountGroup")))
 895	employee		= cint(text2value(request.form("employee")))
 896	website			= left(sqlSafe(Request.form("website")) , 100)
 897	
 898
 899	if not Auth(1 , 4) then ' Doesn't have the permission to set CSR / credit limit
 900		CreditLimit = 0
 901		CSR			= 0
 902		maxCreditDay= 0
 903		maxChequeDay= 0
 904		maxChequeAmount=50000000
 905	else
 906		CSR			= cint(sqlSafe(Request.form("CSR")))
 907		maxCreditDay	= cdbl(text2value(Request.form("maxCreditDay")))
 908		maxChequeDay	= cdbl(text2value(Request.form("maxChequeDay")))
 909		maxChequeAmount	= cdbl(text2value(Request.form("maxChequeAmount")))
 910	end if
 911
 912	AccType			= sqlSafe(Request.form("Type"))
 913	Status			= sqlSafe(Request.form("Status"))
 914	'ACCID			= Request.form("ACCID")
 915
 916	if IsPersonal="on" then
 917		IsPersonal=1
 918	else 
 919		IsPersonal=0
 920	end if
 921
 922	if IsADefault="on" then
 923		IsADefault=1
 924	else 
 925		IsADefault=0
 926	end if
 927
 928	if Postable1="on" then
 929		Postable1=1
 930	else 
 931		Postable1=0
 932	end if
 933
 934	if Postable2="on" then
 935		Postable2=1
 936	else 
 937		Postable2=0
 938	end if
 939
 940	mySQL="SELECT MAX(ID) AS MaxID FROM Accounts WHERE ([ID] <900000)"	
 941	Set RS1=Conn.Execute(mySQL)
 942	NewAccID=RS1("MAXID")+1
 943	RS1.close
 944	Set RS1=Nothing
 945
 946	mySQL="INSERT INTO Accounts (ID, CreatedDate, CreatedBy, LastEditOn, LastEditBy, CSR, IsADefault, EconomicalCode, Type, AccountTitle, IsPersonal, CompanyName, Postable1, Dear1, FirstName1, LastName1, JobTitle1, Tel1, Fax1, EMail1, Mobile1, PostCode1, City1, Address1, Postable2, Dear2, FirstName2, LastName2, JobTitle2, Tel2, Fax2, EMail2, Mobile2, PostCode2, City2, Address2, NorRCode, employee, website,maxCreditDay, maxChequeDay, maxChequeAmount) VALUES ("&_
 947	NewAccID & ", N'"& CreatedDate & "', "& CreatedBy & ", N'"& CreatedDate & "', "& CreatedBy & ", "& CSR & ", "& IsADefault & ", N'"& EconomicalCode & "', "& AccType & ", N'"& AccountTitle & "',"& IsPersonal & ", N'"& CompanyName & "', " & Postable1 & ", N'"& Dear1 & "', N'"& FirstName1 & "', N'"& LastName1 & "', N'"& JobTitle1 & "', N'"& Tel1 & "', N'"& Fax1 & "', N'"& Email1 & "', N'"& Mobile1 & "', N'"& PostCode1 & "', N'"& City1 & "', N'"& Address1 & "', " & Postable2 & ",N'"& Dear2 & "', N'"& FirstName2 & "', N'"& LastName2 & "',  N'"& JobTitle2 & "', N'"& Tel2 & "', N'"& Fax2 & "', N'"& Email2 & "', N'"& Mobile2 & "', N'"& PostCode2 & "', N'"& City2 & "', N'"& Address2 & "', N'" & NorRCode & "', " & employee & ",N'" & website & "'," & maxCreditDay & "," & maxChequeDay & "," & maxChequeAmount & ")"
 948
 949	conn.Execute(mySQL)
 950'	Added By kid 820727 
 951'	-------------------------------
 952'	Log The Insertion
 953	conn.Execute("INSERT INTO AccountsEditLog SELECT '"& CreatedDate & "' AS EditedOn, '"& CreatedBy & "' AS EditedBy,* FROM Accounts WHERE (ID = "& NewAccID & ")")
 954'	End of Log
 955'   -------------------------------
 956
 957	response.redirect "AccountInfo.asp?act=show&selectedCustomer=" & NewAccID & "&msg=" & Server.URLEncode("������� ���� ��� ��.")
 958%>
 959<!-- ������� ����� ��� �� -->
 960	<div dir='rtl' align=center><B>������� ���� ��� ��...</B><br><br>
 961	</div>
 962<%
 963	response.end
 964	RS1.close
 965
 966else if request("act")="" then %>
 967<!-- ����� ���� ��� ���� -->
 968	<BR><BR>
 969	<FORM METHOD=POST ACTION="AccountEdit.asp?act=submitsearch" onsubmit="if (document.all.CustomerNameSearchBox.value=='') return false;">
 970	<div dir='rtl'>&nbsp;&nbsp;<B>��� ��� : ����� ���� ��� ����</B>
 971		<INPUT TYPE="text" NAME="CustomerNameSearchBox">&nbsp;
 972		<INPUT TYPE="submit" value="�����"><br>
 973	</div>
 974	</FORM>
 975	<BR>
 976	<SCRIPT LANGUAGE="JavaScript">
 977	<!--
 978		document.all.CustomerNameSearchBox.focus();
 979	//-->
 980	</SCRIPT>
 981<%
 982end if
 983end if
 984conn.Close
 985%>
 986</font>
 987<br>
 988<script language="JavaScript">
 989<!--
 990function setAccountTitle(){
 991	with (document.all){
 992		if (IsPersonal.checked){
 993			AccountTitle.value= Dear1.value + " " +FirstName1.value + " " +LastName1.value + " "
 994		}
 995		else{
 996			if(Dear1.value+FirstName1.value+LastName1.value != ''){
 997				AccountTitle.value=CompanyName.value + " (" + Dear1.value + " " +FirstName1.value + " " +LastName1.value + ")"
 998			}
 999			else{
1000				AccountTitle.value=CompanyName.value
1001			}
1002		}
1003	}
1004}
1005
1006function showCompanyName(){
1007	if (document.all.IsPersonal.checked){
1008		document.all.CompanyName.style.visibility="hidden";
1009		document.all.lblNorRCode.value="����� ���:";
1010		document.all.employee.style.visibility="hidden";
1011	}
1012	else{
1013		document.all.CompanyName.style.visibility="visible"
1014		document.all.CompanyName.focus();
1015		document.all.lblNorRCode.value="����� ���:";
1016		document.all.employee.style.visibility="visible";
1017	}
1018}
1019//-->
1020</script>
1021<!--#include file="tah.asp" -->