Untitled

TCL Detected Guest 4 Views Size: 58.59 KB Posted on: Nov 8, 26 @ 2:16 AM
  1. File Edit Options Buffers Tools Tcl Help                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  2. ad_page_contract {} {
  3.     {event_id:naturalnum,optional}
  4.     {page:naturalnum,optional}
  5. }
  6.  
  7. ns_log Notice "Running TCL script items.tcl"
  8.  
  9.  
  10. set tree_id [category_tree::get_id "EventsQA" "en_US"]
  11. set categories [category::get_mapped_categories -tree_id $tree_id $event_id]
  12. set category_names [category::get_names $categories "pt_BR"]
  13.  
  14. set item_ids [ee_event::event::matching_items -event_id $event_id]
  15. set count [llength $item_ids]
  16.  
  17.  
  18. set latitude "-12.9704"
  19. set longitude "-38.5124"
  20. set max_distance 50
  21.  
  22.  
  23.  
  24. ns_log Notice "ITEMS $item_ids"
  25. if { [llength $item_ids] > 0 } {
  26. ns_log Notice "$item_ids"
  27.     set item_ids [join [join $item_ids " "] ","]
  28. }
  29.  
  30. ns_log Notice "$item_ids"
  31.  
  32. #ns_log Notice "EVENTTYPES $mapped_objs"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  33. # To use evex QA as extension of cr_items Iuri Sampaio (iuri@iurix.com)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  34. set from_table "ee_qa_item_info qa1, ee_qa_item_category_score qa2 "
  35. append where_clauses " AND qa1.item_id = qa2.item_id "
  36.  
  37. set categories [join $categories ", "]
  38. append where_clauses " AND qa2.category_id IN ($categories) "
  39.  
  40. set order_by " GROUP BY qa1.item_id, qa2.score, cr.title ORDER BY qa2.score DESC, qa1.score DESC"
  41.  
  42.  
  43.  
  44.  
  45.  
  46. set tree_id [category_tree::get_id "Supplier Types" "en_US"]
  47. set serv_categories [category::get_mapped_categories -tree_id $tree_id $event_id]
  48.  
  49. set where_clauses ""
  50. set from_tables ""
  51.  
  52. # Service categories                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  53. if { [llength $serv_categories] } {
  54.     set serv_category_names [category::get_names $serv_categories "pt_BR"]
  55.     set serv_categories [join $serv_categories ", "]
  56.     ns_log Notice "CATEGORIES $serv_categories | NAMES: $serv_category_names"
  57.     set from_tables ", category_object_map com"
  58.     set where_clauses " AND com.object_id = qa1.item_id AND com.category_id IN ($serv_categories)"
  59. }
  60.  
  61.  
  62.  
  63.  
  64. list::create \
  65.     -name items \
  66.     -multirow items \
  67.     -key item_id \
  68.     -page_flush_p 1 \
  69.     -page_size 250 \
  70.     -page_query_name select_items \
  71.     -actions {
  72.         "#evex-event.Send_request#" request-proposal "#evex-event.Send_a_request_to_partner#"
  73.     } \
  74.     -bulk_action_method post \
  75.     -bulk_action_export_vars { event_id } \
  76.     -bulk_actions {
  77.         "#evex-event.Send_request#" request-proposal "#evex-event.Send_request_to_all_partners#"
  78.     } \
  79.     -elements {
  80.         title {
  81.             label "#evex-event.Title#"
  82.         }
  83.         distance {
  84.             label "#evex-event.Distance#"
  85.         }
  86.         score {
  87.             label "#evex-event.Category_Score#"
  88.         }
  89.         total {
  90.             label "#evex-event.Total_Score#"
  91.         }
  92.         serv_category_name {
  93.             label "Servico"
  94.         }
  95.         location {
  96.             label "#evex-event.Location#"
  97.         }
  98.     }
  99.  
  100. db_multirow -extend { thumbnail_url serv_category_name} items select_items_page "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  101.    SELECT qa1.item_id, qa1.score AS total, qa2.score, cr.title,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  102.    pa.latitude, pa.longitude, pa.delivery_address AS location,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  103.    to_char((( 3959 * acos ( cos ( radians(:latitude) ) * cos( radians( CAST(pa.latitude AS NUMERIC)) ) * cos( radians( CAST(pa.longitude AS NUMERIC) ) - radians(:longitude) )+ sin ( radians(:latitude) )* sin( radians( CAST(pa.latitude AS NUMERIC) ) ) )) * 1.6)::float, 'FM999999990.00') AS distance, com.category_id AS serv_category                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  104.    FROM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  105.    cr_items ci, cr_revisions cr,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  106.    ee_qa_item_info qa1, ee_qa_item_category_score qa2,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  107.    postal_addresses pa,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  108.    acs_data_links adl                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  109.    $from_tables                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  110.    WHERE ci.item_id = cr.item_id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  111.    AND ci.live_revision = cr.revision_id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  112.    AND (ci.content_type = 'ee_venue' OR ci.content_type = 'ee_service')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  113.    AND qa1.item_id = ci.item_id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  114.    AND qa1.item_id = qa2.item_id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  115.    AND adl.object_id_one = qa1.item_id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  116.    AND adl.object_id_two = pa.party_id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  117.    AND adl.relation_tag = 'item_group_rel'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  118.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  119.    AND (( 3959 * acos ( cos ( radians(:latitude) ) * cos( radians( CAST(pa.latitude AS NUMERIC)) ) * cos( radians( CAST(pa.longitude AS NUMERIC) ) - radians(:longitude) )+ sin ( radians(:latitude) )* sin( radians( CAST(pa.latitude AS NUMERIC) ) ) )) * 1.6) < :max_distance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  120.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  121.    AND ci.item_id IN ($item_ids)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  122.    AND qa2.category_id IN ($categories)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  123.    $where_clauses                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  124.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  125.    AND [template::list::page_where_clause -name items -key qa1.item_id ]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  126.    [template::list::filter_where_clauses -and -name items]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  127.    GROUP BY qa1.item_id, qa2.score, cr.title, pa.latitude, pa.longitude, pa.delivery_address, com.category_id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  128.    ORDER BY qa2.score DESC, qa1.score DESC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  129.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  130. " {
  131.  
  132.     set thumbnail_url ""
  133.     set serv_category_name [lindex [category::get_names $serv_category "pt_BR"] 0]
  134.  
  135.     #set tree_id [category_tree::get_id "EventosQA" "pt_BR"]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  136.    #set categories [category::get_mapped_categories -tree_id $tree_id $event_id]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  137.    # set category_names [category::get_names $categories "pt_BR"]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  138.    #  ns_log Notice "NAMES $category_names"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  139.    #   set category1_pretty [lindex $category_names 0]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  140.    #    set category2_pretty [lindex $category_names 1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  141.  
  142. }

Raw Paste

Comments 0
Login to post a comment.
  • No comments yet. Be the first.
Login to post a comment. Login or Register
We use cookies. To comply with GDPR in the EU and the UK we have to show you these.

We use cookies and similar technologies to keep this website functional (including spam protection via Google reCAPTCHA or Cloudflare Turnstile), and — with your consent — to measure usage and show ads. See Privacy.