/beta/AR/include_SelectAccount.asp

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