/beta/Inquiry/include_SelectAccount.asp

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