PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/Inquiry/include_SelectAccountAdvanced.asp

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