PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/AR/include_SelectAccountComplex.asp

http://github.com/khaneh/Orders
ASP | 178 lines | 147 code | 15 blank | 16 comment | 25 complexity | 3757f62e295bbc045f2cf244f9236659 MD5 | raw file
  1<%
  2'		This Include File Needs Following Variables to have values:
  3'
  4'		SA_Action				(the Action of the form)
  5'		SA_TitleOrName			(AccountTitle or Name to be searched)
  6'		SA_SearchAgainURL		()
  7'		SA_StepText				(e.g. '��� ��� :')
  8'		SA_ActName				(e.g. 'submitsearch')
  9'		SA_SearchBox			(e.g. 'CustomerNameSearchBox')
 10'		SA_IsVendor 			(is 1 or 0)
 11'
 12'
 13if SA_ActName="" then SA_ActName="submitsearch"
 14if SA_SearchBox="" then SA_SearchBox="CustomerNameSearchBox"
 15
 16		SA_RecordLimit = 20
 17
 18		if SA_IsVendor  = 1  then 
 19			extraConditions = " and [type]=1 "
 20		else
 21			extraConditions = "  "
 22		end if
 23
 24		Set SA_RS1 = Server.CreateObject("ADODB.Recordset")
 25		SA_RS1.CursorLocation=3 '---------- Alix: Because in ADOVBS_INC adUseClient=3
 26
 27		SA_RS1.PageSize = SA_RecordLimit
 28
 29'		SA_mySQL="SELECT *, Users.RealName AS CSRName FROM Accounts LEFT OUTER JOIN Users ON Accounts.CSR = Users.ID WHERE (REPLACE(Accounts.AccountTitle, ' ', '') LIKE REPLACE(N'%"& SA_TitleOrName & "%', ' ', ''))"& extraConditions & " ORDER BY Accounts.AccountTitle"
 30'	Rem By Kid 820728
 31		SA_mySQL="SELECT Accounts.*, Users.RealName AS CSRName FROM Accounts LEFT OUTER JOIN Users ON Accounts.CSR = Users.ID WHERE (REPLACE(Accounts.AccountTitle + ISNULL(Accounts.CompanyName, '') + ISNULL(Accounts.FirstName1, '') + ISNULL(Accounts.LastName1, ''), ' ', '') LIKE REPLACE(N'%"& SA_TitleOrName & "%', ' ', ''))"& extraConditions & " ORDER BY Accounts.AccountTitle"
 32
 33'		SA_RS1.Open SA_mySQL ,Conn,adOpenStatic,,adcmdcommand 
 34		SA_RS1.Open SA_mySQL ,Conn,3,,adcmdcommand 
 35
 36		FilePages = SA_RS1.PageCount
 37
 38		Page=1
 39		if isnumeric(Request.QueryString("p")) then
 40		  if (clng(Request.QueryString("p")) <= FilePages) and clng(Request.QueryString("p") > 0) then
 41			Page=clng(Request.QueryString("p"))
 42		  end if
 43		end if
 44
 45		if not SA_RS1.eof then
 46			SA_RS1.AbsolutePage=Page
 47		end if
 48
 49		if (SA_RS1.eof) then 
 50					response.redirect "?errmsg=" & Server.URLEncode("���� ����� ���� ���.<br><a href='../CRM/AccountEdit.asp?act=getAccount'>���� ���Ͽ</a>")
 51
 52		' Not Found	%>
 53
 54		<div dir='rtl'><B>���� ����� ���� ���</B> &nbsp; <A HREF="<%=SA_SearchAgainURL%>" style='font-size:7pt;'>������ ����</A>
 55		</div><br>
 56	<%	else %><br>
 57		<div dir='rtl'><B><%=SA_StepText%></B>
 58		</div><br>
 59<!-- ������ ���� --> 
 60		<table style="font-family:tahoma;font-size:9pt; border:1 dashed #888888; direction:RTL;" align="center" Width="90%" Cellspacing="0" Cellpadding="5">
 61		<tbody id="AccountsTable">
 62				<tr bgcolor='#33AACC'>
 63					<td style="width:10px;"> # </td>
 64					<td><INPUT TYPE="radio" NAME="O" checked disabled></td>
 65					<td> ����� ���� </td>
 66					<td> ��� ����</td>
 67					<td> ��� ���� ��� </td>
 68					<td width='50px'> ����� ������ </td>
 69					<td width='70px'> ����� ����</td>
 70					<td width='70px'> ����� ����</td>
 71				</tr>
 72	<%		
 73			SA_tempCounter= (Page - 1 ) * SA_RecordLimit
 74			while Not ( SA_RS1.EOF)   and (SA_RS1.AbsolutePage = Page)
 75				'SA_OldAccountNo=SA_RS1("ACCID")
 76				SA_AccountNo=SA_RS1("ID")
 77				SA_AccountTitle=SA_RS1("AccountTitle")
 78				SA_totalBalance=SA_RS1("ARBalance")
 79				SA_totalBalanceAP=SA_RS1("APBalance")
 80				SA_totalBalanceAO=SA_RS1("AOBalance")
 81				if SA_RS1("Type") = 1 then 
 82					SA_AccountTitle = SA_AccountTitle & " (�������) "
 83				end if
 84				if isnull(SA_totalBalance) then
 85					SA_totalBalance=0
 86					SA_totalBalanceText="<i>N / A</i>"
 87					SA_tempBalanceColor="gray"
 88				else
 89					SA_totalBalanceText=Separate(SA_totalBalance)
 90					if (cdbl(SA_totalBalance) >= 0 )then
 91						SA_tempBalanceColor="green"
 92					else
 93						SA_tempBalanceColor="red"
 94					end if
 95				end if
 96				SA_tempCounter=SA_tempCounter+1
 97				if (SA_tempCounter Mod 2 = 1)then
 98					SA_tempColor="#FFFFFF"
 99				else
100					SA_tempColor="#DDDDDD"
101				end if
102
103	%>				<tr>
104						<td style="border-bottom: solid 1pt black"><%=SA_tempCounter %>&nbsp;</td>
105						<td  style="border-bottom: solid 1pt black;"><INPUT TYPE="radio" NAME="selectedCustomer" Value="<%=SA_RS1("ID")%>"  <% if SA_RS1("status")="3" then %> disabled <% end if %>  onclick="okToProceed=true;setColor(this)" ></td>
106						<td  style="border-bottom: solid 1pt black">
107						<%if Auth(1 , 1) then %>
108							<A href="../CRM/AccountInfo.asp?act=show&selectedCustomer=<%=SA_AccountNo%>" target='_blank'><%=SA_AccountTitle%></A>  <% if SA_RS1("status")="3" then %> <FONT COLOR="red"><B>�����</B></FONT> <% end if %> 
109						<%else
110							response.write SA_AccountTitle
111						end if%>
112						&nbsp;</td>
113						<td  style="border-bottom: solid 1pt black;"><%=SA_RS1("�CompanyName")%>&nbsp;</td>
114						<td  style="border-bottom: solid 1pt black"><%=SA_RS1("Dear1")& " " & SA_RS1("FirstName1")& " " & SA_RS1("LastName1")%>&nbsp;</td>
115						<td  style="border-bottom: solid 1pt black"><B><FONT Color='blue'><%=SA_RS1("CSRName")%></FONT></B>&nbsp;</td>
116						<td  style="border-bottom: solid 1pt black; direction:LTR; text-align:right;"><FONT COLOR="<%=SA_tempBalanceColor%>"><%=SA_totalBalanceText%></FONT>&nbsp;</td>
117						<td  style="border-bottom: solid 1pt black; direction:LTR; text-align:right;"><FONT COLOR="black"><%=Separate(SA_totalBalanceAP)%></FONT>&nbsp;</td>
118					</tr>
119	<%			SA_RS1.movenext
120			wend
121	%>
122			<tr bgcolor='#33AACC'>
123				<td align='right' colspan=3>
124					<INPUT class="GenButton" TYPE="submit" name="submitSelection" value="������" onclick="<%=SA_Action%>">
125
126	<SCRIPT LANGUAGE="JavaScript">
127	<!--
128	if (! window.dialogArguments){// if this is NOT a modal window
129		document.write('&nbsp;&nbsp; <INPUT class="GenButton" TYPE="button" name="submitSelection" value="����" onclick="window.location=\'../CRM/AccountEdit.asp?act=getAccount\'">');
130	}
131	//-->
132	</SCRIPT>
133				</td>
134				<td align='center' colspan="7" dir="RTL">&nbsp;<span id="sa_links">
135	<%
136			if FilePages>1 then
137				response.write "���� &nbsp;"
138				for i=1 to FilePages 
139					if i = page then %>
140						[<%=i%>]&nbsp;
141<%					else%>
142						<A HREF="?p=<%=i%>&<%=SA_SearchBox%>=<%=SA_TitleOrName%>&act=<%=SA_ActName%>"><%=i%></A>&nbsp;
143<%					end if 
144				next 
145			end if
146%>
147				</span></td>
148			</tr>
149		</tbody>
150		</table>
151<SCRIPT LANGUAGE="JavaScript">
152<!--
153function setColor(obj)
154{
155	for(i=0; i<document.all.selectedCustomer.length; i++)
156		{
157		theTR = document.all.selectedCustomer[i].parentNode.parentNode
158		theTR.setAttribute("bgColor","#C3DBEB")
159		}
160	theTR = obj.parentNode.parentNode
161	theTR.setAttribute("bgColor","#FFFFFF")
162}
163
164radio1=document.getElementsByName("selectedCustomer")[0];
165radio1.checked=true;
166okToProceed=true;
167setColor(radio1);
168if (window.dialogArguments){// if this is a modal window
169	if (document.all.selectedCustomer.length==<%=SA_RecordLimit%>)
170		document.getElementById("sa_links").innerText="����� ���� �� ����� �� ��� ��� ... ����� �� ����� �� ����";
171	else
172		document.getElementById("sa_links").innerText="";
173}else{
174	radio1.focus();
175}
176//-->
177</SCRIPT>
178	<%	end if%>