Advertisement
infowebadmin

espresso_tabletest.php

Mar 28th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. <?php
  2. /*
  3. Shortcode Name: Espresso Table
  4. Author: Seth Shoultes
  5. Contact: seth@eventespresso.com
  6. Website: http://www.eventespresso.com
  7. Description: Only show events in a CATEGORY within a certain number number of days into the future and a qty. The example below only shows events in a certain category that start within 30 days from the current date.
  8. Usage Example: [ESPRESSO_TABLE max_days="30" qty="3" category_id="gracecard" order_by="state"]
  9. Custom CSS for the table display
  10. Notes: This file should be stored in your "/wp-content/uploads/espresso/templates/" folder and you should have the custom_includes.php files installed in your "/wp-content/uploads/espresso/" directory.
  11. */
  12. function espresso_display_tabletest($atts){
  13. global $wpdb;
  14. $org_options = get_option('events_organization_settings');
  15. $event_page_id =$org_options['event_page_id'];
  16.  
  17. global $load_espresso_scripts;
  18. $load_espresso_scripts = true;//This tells the plugin to load the required scripts
  19. extract(shortcode_atts(array('event_category_id'=>'NULL','category_identifier' => 'NULL','show_expired' => 'false', 'show_secondary'=>'false','show_deleted'=>'false','show_recurrence'=>'true', 'limit' => '0', 'order_by' => 'NULL', 'max_days'=>''),$atts));
  20.  
  21. if ($category_identifier != 'NULL'){
  22. $type = 'category';
  23. }
  24.  
  25. $show_expired = $show_expired == 'false' ? " AND e.start_date >= '".date ( 'Y-m-d' )."' " : '';
  26. $show_secondary = $show_secondary == 'false' ? " AND e.event_status != 'S' " : '';
  27. $show_deleted = $show_deleted == 'false' ? " AND e.event_status != 'D' " : '';
  28. $show_recurrence = $show_recurrence == 'false' ? " AND e.recurrence_id = '0' " : '';
  29. $limit = $limit > 0 ? " LIMIT 0," . $limit . " " : '';
  30. $order_by = $order_by != 'NULL'? " ORDER BY ". $order_by ." ASC " : " ORDER BY date(start_date), id ASC ";
  31.  
  32. if ($type == 'category'){
  33. $sql = "SELECT e.* FROM " . EVENTS_CATEGORY_TABLE . " c ";
  34. $sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.cat_id = c.id ";
  35. $sql .= " JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = r.event_id ";
  36. $sql .= " WHERE c.category_identifier = '" . $category_identifier . "' ";
  37. $sql .= " AND e.is_active = 'Y' ";
  38. }else{
  39. $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e ";
  40. $sql .= " WHERE e.is_active = 'Y' ";
  41. }
  42. if ($max_days != ""){
  43. $sql .= " AND ADDDATE('".date ( 'Y-m-d' )."', INTERVAL ".$max_days." DAY) >= e.start_date AND e.start_date >= '".date ( 'Y-m-d' )."' ";
  44. }
  45. $sql .= $show_expired;
  46. $sql .= $show_secondary;
  47. $sql .= $show_deleted;
  48. $sql .= $show_recurrence;
  49. $sql .= $order_by;
  50. $sql .= $limit;
  51.  
  52. echo espresso_get_table($sql);
  53.  
  54. }
  55. //Events Custom Table Listing - Shows the events on your page in matching table.
  56. function espresso_get_tabletest($sql){
  57. global $wpdb, $org_options;
  58. //echo 'This page is located in ' . get_option( 'upload_path' );
  59. $event_page_id = $org_options['event_page_id'];
  60. $currency_symbol = $org_options['currency_symbol'];
  61. $events = $wpdb->get_results($sql);
  62.  
  63. $category_name = $wpdb->last_result[0]->category_name;
  64. $category_desc = $wpdb->last_result[0]->category_desc;
  65. $display_desc = $wpdb->last_result[0]->display_desc;
  66. if ($display_desc == 'Y'){
  67. echo '<p>' . stripslashes_deep($category_name) . '</p>';
  68. echo '<p>' . stripslashes_deep($category_desc) . '</p>';
  69. }
  70. ?>
  71. <table class="espresso-table" width="100%">
  72.  
  73. <thead class="espresso-table-header-row">
  74. <tr>
  75. <th class="th-group"><?php _e('Course','event_espresso'); ?></th>
  76. <th class="th-group"><?php _e('','event_espresso'); ?></th>
  77. </tr>
  78. </thead>
  79. <tbody>
  80.  
  81. <?php
  82.  
  83. foreach ($events as $event){
  84. $reg_limit = $event->reg_limit;
  85.  
  86.  
  87. $event_desc = wpautop($event->event_desc);
  88.  
  89. $register_button = '<a id="a_register_link-'.$event->id.'" href="'.get_option('siteurl').'/?page_id='.$event_page_id.'&regevent_action=register&event_id='.$event->id.'&name_of_event='.stripslashes_deep($event->event_name).'">View Details</a>';
  90.  
  91. //Check to see how many open spots are available
  92. $open_spots = get_number_of_attendees_reg_limit($event->id, 'available_spaces') == 'Unlimited' ? 999 : get_number_of_attendees_reg_limit($event->id, 'available_spaces');
  93. //echo $open_spots;
  94.  
  95. if ( $open_spots < 1 ) { $live_button = 'Closed'; }
  96.  
  97. ?>
  98. <tr class="espresso-table-row">
  99. <td class="td-group">
  100. <?php echo stripslashes_deep($event->event_name) ?>
  101. </td>
  102. <td class="td-group">
  103. <?php echo $register_button ?>
  104. </td>
  105. </tr>
  106. <?php } //close foreach ?>
  107. </tbody>
  108. </table>
  109.  
  110. <?php
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement