Advertisement
infowebadmin

espresso_tabletest.php

Mar 28th, 2013
72
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. Website: http://www.eventespresso.com
  6. 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.
  7. Usage Example: [ESPRESSO_TABLE max_days="30" qty="3" category_id="gracecard" order_by="state"]
  8. Custom CSS for the table display
  9. 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.
  10. */
  11. function espresso_display_tabletest($atts){
  12. global $wpdb;
  13. $org_options = get_option('events_organization_settings');
  14. $event_page_id =$org_options['event_page_id'];
  15.  
  16. global $load_espresso_scripts;
  17. $load_espresso_scripts = true;//This tells the plugin to load the required scripts
  18. 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));
  19.  
  20. if ($category_identifier != 'NULL'){
  21. $type = 'category';
  22. }
  23.  
  24. $show_expired = $show_expired == 'false' ? " AND e.start_date >= '".date ( 'Y-m-d' )."' " : '';
  25. $show_secondary = $show_secondary == 'false' ? " AND e.event_status != 'S' " : '';
  26. $show_deleted = $show_deleted == 'false' ? " AND e.event_status != 'D' " : '';
  27. $show_recurrence = $show_recurrence == 'false' ? " AND e.recurrence_id = '0' " : '';
  28. $limit = $limit > 0 ? " LIMIT 0," . $limit . " " : '';
  29. $order_by = $order_by != 'NULL'? " ORDER BY ". $order_by ." ASC " : " ORDER BY date(start_date), id ASC ";
  30.  
  31. if ($type == 'category'){
  32. $sql = "SELECT e.* FROM " . EVENTS_CATEGORY_TABLE . " c ";
  33. $sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.cat_id = c.id ";
  34. $sql .= " JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = r.event_id ";
  35. $sql .= " WHERE c.category_identifier = '" . $category_identifier . "' ";
  36. $sql .= " AND e.is_active = 'Y' ";
  37. }else{
  38. $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e ";
  39. $sql .= " WHERE e.is_active = 'Y' ";
  40. }
  41. if ($max_days != ""){
  42. $sql .= " AND ADDDATE('".date ( 'Y-m-d' )."', INTERVAL ".$max_days." DAY) >= e.start_date AND e.start_date >= '".date ( 'Y-m-d' )."' ";
  43. }
  44. $sql .= $show_expired;
  45. $sql .= $show_secondary;
  46. $sql .= $show_deleted;
  47. $sql .= $show_recurrence;
  48. $sql .= $order_by;
  49. $sql .= $limit;
  50.  
  51. echo espresso_get_table($sql);
  52.  
  53. }
  54. //Events Custom Table Listing - Shows the events on your page in matching table.
  55. function espresso_get_tabletest($sql){
  56. global $wpdb, $org_options;
  57. //echo 'This page is located in ' . get_option( 'upload_path' );
  58. $event_page_id = $org_options['event_page_id'];
  59. $currency_symbol = $org_options['currency_symbol'];
  60. $events = $wpdb->get_results($sql);
  61.  
  62. $category_name = $wpdb->last_result[0]->category_name;
  63. $category_desc = $wpdb->last_result[0]->category_desc;
  64. $display_desc = $wpdb->last_result[0]->display_desc;
  65. if ($display_desc == 'Y'){
  66. echo '<p>' . stripslashes_deep($category_name) . '</p>';
  67. echo '<p>' . stripslashes_deep($category_desc) . '</p>';
  68. }
  69. ?>
  70. <table class="espresso-table" width="100%">
  71.  
  72. <thead class="espresso-table-header-row">
  73. <tr>
  74. <th class="th-group"><?php _e('Course','event_espresso'); ?></th>
  75. <th class="th-group"><?php _e('','event_espresso'); ?></th>
  76. </tr>
  77. </thead>
  78. <tbody>
  79.  
  80. <?php
  81.  
  82. foreach ($events as $event){
  83. $reg_limit = $event->reg_limit;
  84.  
  85.  
  86. $event_desc = wpautop($event->event_desc);
  87.  
  88. $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>';
  89.  
  90. //Check to see how many open spots are available
  91. $open_spots = get_number_of_attendees_reg_limit($event->id, 'available_spaces') == 'Unlimited' ? 999 : get_number_of_attendees_reg_limit($event->id, 'available_spaces');
  92. //echo $open_spots;
  93.  
  94. if ( $open_spots < 1 ) { $live_button = 'Closed'; }
  95.  
  96. ?>
  97. <tr class="espresso-table-row">
  98. <td class="td-group">
  99. <?php echo stripslashes_deep($event->event_name) ?>
  100. </td>
  101. <td class="td-group">
  102. <?php echo $register_button ?>
  103. </td>
  104. </tr>
  105. <?php } //close foreach ?>
  106. </tbody>
  107. </table>
  108.  
  109. <?php
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement