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