Advertisement
Guest User

Untitled

a guest
Jun 4th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 6.83 KB | None | 0 0
  1. <div class="Content">
  2.     <% showHeader(100) %>
  3.  
  4.     <!--#INCLUDE FILE="inc/common/dept_top.asp" -->
  5.  
  6.     <%
  7.     show_all = nz(mscsPage.RequestNumber("show_all", 0), 0)
  8.    
  9.     If show_all = 1 Then
  10.         str_priority = ""
  11.     Else
  12.         str_priority = " AND c.priority < 50 "
  13.     End If
  14.  
  15.     'call WriteVar("CallFrom", false)
  16.     'call WriteVar("show_all", false)
  17.     'call WriteVar("str_priority", false)
  18.    
  19.     'if request("call_from").count > 0 and CallFrom <> "US Continental" then
  20.     if CallFrom <> "" AND CallFrom <> "US Continental" then
  21.             call_from = split(CallFrom,",")
  22.             call_from_country = call_from(0)
  23.            
  24.             if ubound(call_from) > 0 then
  25.                 call_from_state = Trim(call_from(1))
  26.                
  27.                 cmdTemp.CommandText = "SELECT c.country, " & _
  28.                                              "r.per_min + ia.surcharge AS cost_per_min, " & _
  29.                                              "c.priority " & _
  30.                                       "FROM discall_country c " & _
  31.                                         "INNER JOIN  discall_rates r ON " & _
  32.                                             "c.id = r.call_to " & _
  33.                                         "INNER JOIN  international_access ia ON " & _
  34.                                             "r.dept_id = ia.dept_id " & _
  35.                                         "INNER JOIN  discall_dept d ON " & _
  36.                                             "ia.dept_id = d.dept_id " & _
  37.                                       "WHERE d.dept_id = " & dept_id & _
  38.                                         " AND  r.call_from = 1 " & _
  39.                                         " AND ia.country = " & SQLCode(call_from_country) & _
  40.                                         " AND (ia.state = " & SQLCode(call_from_state) & _
  41.                                                 " OR ia.city = " & SQLCode(call_from_state) & ") " & _
  42.                                         str_priority & _
  43.                                       "ORDER BY c.country, cost_per_min"
  44.  
  45.                                      '" AND c.country NOT IN ('Lebanon', 'LEBANON CELL', 'Sudan', 'Ethiopia', 'ETHIOPIA CELL', 'Eritrea', 'Syria') " & _
  46.                                      '"Convert(VarChar(10), r.per_min + ia.surcharge) AS cost_per_min, " & _
  47.                                    
  48.                                     'call showQuery(cmdTemp.CommandText, -1, MSCS)
  49.             else
  50.  
  51.                 cmdTemp.CommandText = "SELECT c.country, " & _
  52.                                              "r.per_min + ia.surcharge AS cost_per_min, " & _
  53.                                              "c.priority, " & _
  54.                                              "r.call_from, " & _
  55.                                              "r.call_to " & _
  56.                                       "FROM discall_country c " & _
  57.                                         "INNER JOIN  discall_rates r ON " & _
  58.                                             "c.id = r.call_to " & _
  59.                                         "INNER JOIN  international_access ia ON " & _
  60.                                             "r.dept_id = ia.dept_id " & _
  61.                                         "INNER JOIN  discall_dept d ON " & _
  62.                                             "ia.dept_id = d.dept_id " & _
  63.                                       "WHERE d.dept_id = " & dept_id & _
  64.                                         " AND  r.call_from = 1 " & _
  65.                                         " AND ia.country = " & SQLCode(call_from_country) & _
  66.                                         " AND ISNULL(ia.state, '') = '' " & _
  67.                                         " AND ISNULL(ia.city, '') = '' " & _
  68.                                         str_priority & _
  69.                                       "ORDER BY c.country, cost_per_min"
  70.  
  71.                 '" AND c.country NOT IN ('Lebanon', 'LEBANON CELL', 'Sudan', 'Ethiopia', 'ETHIOPIA CELL', 'Eritrea', 'Syria') " & _
  72.                 'call showQuery(cmdTemp.CommandText, -1, MSCS)
  73.             end if
  74.     else
  75.             cmdTemp.CommandText = "SELECT " & _
  76.                                             "c.country, " & _
  77.                                             "r.per_min AS cost_per_min, " & _
  78.                                             "c.priority " & _
  79.                                     "FROM discall_rates r " & _
  80.                                         "INNER JOIN discall_country c ON " & _
  81.                                             "r.call_to = c.Id " & _
  82.                                     "WHERE r.dept_id = " & dept_id & _
  83.                                         str_priority & _
  84.                                     " ORDER BY c.country, cost_per_min "
  85.  
  86.                                     '" AND c.country NOT IN ('Lebanon', 'LEBANON CELL', 'Sudan', 'Ethiopia', 'ETHIOPIA CELL', 'Eritrea', 'Syria') " & _
  87.     end if
  88.  
  89.     'call showQuery(cmdTemp.CommandText, -1, MSCS)
  90.  
  91.     Dim rsRates, aRates, last_rec, max_cols, max_rows
  92.     Dim ii, jj, kk
  93.  
  94.     Set rsRates = cmdTemp.Execute()
  95.  
  96.     on error resume next
  97.  
  98.     If Not rsRates.EOF Then
  99.         aRates = rsRates.GetRows()
  100.  
  101.         last_rec = Ubound(aRates, 2) + 1
  102.     Else
  103.         last_rec = 0
  104.     End If
  105.  
  106.     rsRates.Close()
  107.  
  108.  
  109.     ' ѕерекачаем массив aRates в mass_rates - чтобы оставить уникальные
  110.     ' страны (и вз¤ть дл¤ них, соответственно, самый дешЄвый тариф)
  111.     Dim mass_rates: mass_rates = Array()
  112.    
  113.     last_rec = 0
  114.  
  115.     mass_ubound = Ubound(aRates, 2)
  116.  
  117.     For jj = 0 To mass_ubound
  118.         cur_country = Trim(aRates(0, jj) & "")
  119.         'Response.Write ("cur_country = " & cur_country & "<br>")
  120.        
  121.         For jjj = jj + 1 To mass_ubound
  122.             country = Trim(aRates(0, jjj) & "")
  123.  
  124.             If country <> cur_country OR jjj = mass_ubound Then
  125.  
  126.                 new_ubound = Ubound(mass_rates) + 1
  127.  
  128.                 Redim Preserve mass_rates (new_ubound)
  129.                 mass_rates (new_ubound) = Array(aRates(0, jj), aRates(1, jj), aRates(2, jj))
  130.            
  131.                 jj = jjj - 1
  132.  
  133.                 last_rec = last_rec + 1
  134.  
  135.                 Exit For
  136.             End If
  137.         Next
  138.        
  139.     Next
  140.  
  141.     'Response.Write ("last_rec = " & last_rec & "<br>")
  142.  
  143.     'For ii = 0 To UBound(mass_rates)
  144.     '    Response.Write ("cur_country = " & mass_rates(ii)(0) & "<br>")
  145.     'Next
  146.  
  147.     'call WriteVar("new_ubound", false)
  148.    
  149.     max_cols = 2
  150.  
  151.     max_rows = Int(last_rec / max_cols)
  152.  
  153.     'call WriteVar("last_rec", false)
  154.     'call WriteVar("max_rows", false)
  155.  
  156.     If max_rows * max_cols < last_rec Then
  157.         max_rows = max_rows + 1
  158.     End If
  159.     %>
  160.  
  161.     <div class="FirstColumn">
  162.         <table border="0" class="SimpleView" width="100%" cellpadding="0" cellspacing="0">
  163.  
  164.             <%
  165.             For ii = 0 To max_rows - 1
  166.        
  167.                 'price = Split(FormatCents(aRates(1, ii) / 100), " ")
  168.                 price = Split(FormatCents(mass_rates(ii)(1) / 100), " ")
  169.             %>
  170.                 <tr>
  171.                     <td><%= mass_rates(ii)(0) %><%'= aRates(0, ii) %></td>
  172.                     <td align="right"><b><%= price(0) %></b></td>
  173.                     <td width="35"><%= price(1) %>/min</td>
  174.                 </tr>
  175.             <%
  176.                 If ii < max_rows - 1 Then
  177.                     call line_dot
  178.                 End If
  179.             Next
  180.             %>
  181.  
  182.         </table>
  183.     </div>
  184.  
  185.     <div class="SecondColumn">
  186.         <table border="0" class="SimpleView" width="100%" cellpadding="0" cellspacing="0">
  187.  
  188.             <%
  189.             kk = ii
  190.             For ii = kk To last_rec - 1 'max_rows - 1
  191.  
  192.                 'price = Split(FormatCents(aRates(1, ii) / 100), " ")
  193.                 price = Split(FormatCents(mass_rates(ii)(1) / 100), " ")
  194.             %>
  195.                 <tr>
  196.                     <td><%= mass_rates(ii)(0) %><%'= aRates(0, ii) %></td>
  197.                     <td align="right"><b><%= price(0) %></b></td>
  198.                     <td width="35"><%= price(1) %>/min</td>
  199.                 </tr>
  200.             <%
  201.                 If ii < last_rec - 1 Then
  202.                     call line_dot
  203.                 End If
  204.             Next
  205.  
  206.             on error goto 0
  207.             %>
  208.  
  209.         </table>
  210.     </div>
  211.  
  212.     <div class="Division"></div>
  213.     <div class="ShowAll"><a HREF="javascript: checkFormRates()">See all rates</a></div>        
  214.     <div class="Division"></div>
  215.  
  216.     <!--#INCLUDE FILE="inc/common/dept_bottom.asp" -->
  217.  
  218. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement