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