Advertisement
eventsmanager

Frontend Events Management With View Event

Apr 2nd, 2019
1,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.14 KB | None | 0 0
  1. <?php
  2. //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
  3. global $wpdb, $bp, $EM_Notices;
  4. /* @var $args array */
  5. /* @var $EM_Events array */
  6. /* @var $events_count int */
  7. /* @var $future_count int */
  8. /* @var $past_count int */
  9. /* @var $pending_count int */
  10. /* @var $url string */
  11. /* @var $show_add_new bool */
  12. /* @var $limit int */
  13. //add new button will only appear if called from em_event_admin template tag, or if the $show_add_new var is set
  14. ?>
  15. <div class="em-events-admin-list">
  16. <?php
  17. echo $EM_Notices;
  18. if(!empty($show_add_new) && current_user_can('edit_events')) echo '<a class="em-button button add-new-h2" href="'.em_add_get_params($_SERVER['REQUEST_URI'],array('action'=>'edit','scope'=>null,'status'=>null,'event_id'=>null, 'success'=>null)).'">'.__('Add New','events-manager').'</a>';
  19. ?>
  20. <form id="posts-filter" action="" method="get">
  21. <div class="subsubsub">
  22. <?php $default_params = array('scope'=>null,'status'=>null,'em_search'=>null,'pno'=>null); //template for cleaning the link for each view below ?>
  23. <a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'future')); ?>' <?php echo ( !isset($_GET['view']) ) ? 'class="current"':''; ?>><?php _e ( 'Upcoming', 'events-manager'); ?> <span class="count">(<?php echo $future_count; ?>)</span></a> &nbsp;|&nbsp;
  24. <?php if( $pending_count > 0 ): ?>
  25. <a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'pending')); ?>' <?php echo ( isset($_GET['view']) && $_GET['view'] == 'pending' ) ? 'class="current"':''; ?>><?php _e ( 'Pending', 'events-manager'); ?> <span class="count">(<?php echo $pending_count; ?>)</span></a> &nbsp;|&nbsp;
  26. <?php endif; ?>
  27. <?php if( $draft_count > 0 ): ?>
  28. <a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'draft')); ?>' <?php echo ( isset($_GET['view']) && $_GET['view'] == 'draft' ) ? 'class="current"':''; ?>><?php _e ( 'Draft', 'events-manager'); ?> <span class="count">(<?php echo $draft_count; ?>)</span></a> &nbsp;|&nbsp;
  29. <?php endif; ?>
  30. <a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'past')); ?>' <?php echo ( isset($_GET['view']) && $_GET['view'] == 'past' ) ? 'class="current"':''; ?>><?php _e ( 'Past Events', 'events-manager'); ?> <span class="count">(<?php echo $past_count; ?>)</span></a>
  31. </div>
  32. <p class="search-box">
  33. <label class="screen-reader-text" for="post-search-input"><?php _e('Search Events','events-manager'); ?>:</label>
  34. <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_REQUEST['em_search'])) ? esc_attr($_REQUEST['em_search']):''; ?>" />
  35. <?php if( !empty($_REQUEST['view']) ): ?>
  36. <input type="hidden" name="view" value="<?php echo esc_attr($_REQUEST['view']); ?>" />
  37. <?php endif; ?>
  38. <input type="submit" value="<?php _e('Search Events','events-manager'); ?>" class="button" />
  39. </p>
  40. <div class="tablenav">
  41. <?php
  42. if ( $events_count >= $limit ) {
  43. $events_nav = em_admin_paginate( $events_count, $limit, $page);
  44. echo $events_nav;
  45. }
  46. ?>
  47. <br class="clear" />
  48. </div>
  49.  
  50. <?php
  51. if ( empty($EM_Events) ) {
  52. echo get_option ( 'dbem_no_events_message' );
  53. } else {
  54. ?>
  55.  
  56. <table class="widefat events-table">
  57. <thead>
  58. <tr>
  59. <?php /*
  60. <th class='manage-column column-cb check-column' scope='col'>
  61. <input class='select-all' type="checkbox" value='1' />
  62. </th>
  63. */ ?>
  64. <th><?php _e ( 'Name', 'events-manager'); ?></th>
  65. <th>&nbsp;</th>
  66. <th><?php _e ( 'Location', 'events-manager'); ?></th>
  67. <th colspan="2"><?php _e ( 'Date and time', 'events-manager'); ?></th>
  68. <th> View Event </th>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. <?php
  73. $rowno = 0;
  74. foreach ( $EM_Events as $EM_Event ) {
  75. /* @var $EM_Event EM_Event */
  76. $rowno++;
  77. $class = ($rowno % 2) ? 'alternate' : '';
  78. $location_summary = "<b>" . esc_html($EM_Event->get_location()->location_name) . "</b><br/>" . esc_html($EM_Event->get_location()->location_address) . " - " . esc_html($EM_Event->get_location()->location_town);
  79.  
  80. if( $EM_Event->start()->getTimestamp() < time() && $EM_Event->end()->getTimestamp() < time() ){
  81. $class .= " past";
  82. }
  83. //Check pending approval events
  84. if ( !$EM_Event->get_status() ){
  85. $class .= " pending";
  86. }
  87. ?>
  88. <tr class="event <?php echo trim($class); ?>" id="event_<?php echo $EM_Event->event_id ?>">
  89. <?php /*
  90. <td>
  91. <input type='checkbox' class='row-selector' value='<?php echo $EM_Event->event_id; ?>' name='events[]' />
  92. </td>
  93. */ ?>
  94. <td>
  95. <strong>
  96. <a class="row-title" href="<?php echo esc_url($EM_Event->get_edit_url()); ?>"><?php echo esc_html($EM_Event->event_name); ?></a>
  97. </strong>
  98. <?php
  99. if( get_option('dbem_rsvp_enabled') == 1 && $EM_Event->event_rsvp == 1 ){
  100. ?>
  101. <br/>
  102. <a href="<?php echo $EM_Event->get_bookings_url(); ?>"><?php esc_html_e("Bookings",'events-manager'); ?></a> &ndash;
  103. <?php esc_html_e("Booked",'events-manager'); ?>: <?php echo $EM_Event->get_bookings()->get_booked_spaces()."/".$EM_Event->get_spaces(); ?>
  104. <?php if( get_option('dbem_bookings_approval') == 1 ): ?>
  105. | <?php _e("Pending",'events-manager') ?>: <?php echo $EM_Event->get_bookings()->get_pending_spaces(); ?>
  106. <?php endif;
  107. }
  108. ?>
  109. <div class="row-actions">
  110. <?php if( current_user_can('delete_events')) : ?>
  111. <span class="trash"><a href="<?php echo esc_url(add_query_arg(array('action'=>'event_delete', 'event_id'=>$EM_Event->event_id, '_wpnonce'=> wp_create_nonce('event_delete_'.$EM_Event->event_id)))); ?>" class="em-event-delete"><?php _e('Delete','events-manager'); ?></a></span>
  112. <?php endif; ?>
  113. </div>
  114. </td>
  115. <td>
  116. <a href="<?php echo $EM_Event->duplicate_url(); ?>" title="<?php _e ( 'Duplicate this event', 'events-manager'); ?>">
  117. <strong>+</strong>
  118. </a>
  119. </td>
  120. <td>
  121. <?php echo $location_summary; ?>
  122. </td>
  123. <td>
  124. <?php echo $EM_Event->output_dates(); ?>
  125. <br />
  126. <?php echo $EM_Event->output_times(); ?>
  127. </td>
  128. <td>
  129. <?php
  130. if ( $EM_Event->is_recurrence() ) {
  131. $recurrence_delete_confirm = __('WARNING! You will delete ALL recurrences of this event, including booking history associated with any event in this recurrence. To keep booking information, go to the relevant single event and save it to detach it from this recurrence series.','events-manager');
  132. ?>
  133. <strong>
  134. <?php echo $EM_Event->get_recurrence_description(); ?> <br />
  135. <a href="<?php echo esc_url($EM_Event->get_edit_reschedule_url()); ?>"><?php _e ( 'Edit Recurring Events', 'events-manager'); ?></a>
  136. <?php if( current_user_can('delete_events')) : ?>
  137. <span class="trash"><a href="<?php echo esc_url(add_query_arg(array('action'=>'event_delete', 'event_id'=>$EM_Event->recurrence_id, '_wpnonce'=> wp_create_nonce('event_delete_'.$EM_Event->recurrence_id)))); ?>" class="em-event-rec-delete" onclick ="if( !confirm('<?php echo $recurrence_delete_confirm; ?>') ){ return false; }"><?php _e('Delete','events-manager'); ?></a></span>
  138. <?php endif; ?>
  139. </strong>
  140. <?php
  141. }
  142. ?>
  143. </td>
  144.  
  145. <td>
  146. <a class="row-title" href="<?php echo $EM_Event->output('#_EVENTURL'); ?>"> View </a>
  147. </td>
  148.  
  149. </tr>
  150. <?php
  151. }
  152. ?>
  153. </tbody>
  154. </table>
  155. <?php
  156. } // end of table
  157. ?>
  158. <div class='tablenav'>
  159. <div class="alignleft actions">
  160. <br class='clear' />
  161. </div>
  162. <?php if ( $events_count >= $limit ) : ?>
  163. <div class="tablenav-pages">
  164. <?php
  165. echo $events_nav;
  166. ?>
  167. </div>
  168. <?php endif; ?>
  169. <br class='clear' />
  170. </div>
  171. </form>
  172. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement