Advertisement
eventsmanager

My Bookings page with Attendee Form List

Oct 13th, 2014
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. <?php do_action('em_template_my_bookings_header'); ?>
  2. <?php
  3. global $wpdb, $current_user, $EM_Notices, $EM_Person;
  4. if( is_user_logged_in() ):
  5. $EM_Person = new EM_Person( get_current_user_id() );
  6. $EM_Bookings = $EM_Person->get_bookings();
  7. $bookings_count = count($EM_Bookings->bookings);
  8. if($bookings_count > 0){
  9. //Get events here in one query to speed things up
  10. $event_ids = array();
  11. foreach($EM_Bookings as $EM_Booking){
  12. $event_ids[] = $EM_Booking->event_id;
  13. }
  14. }
  15. $limit = ( !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
  16. $page = ( !empty($_GET['pno']) ) ? $_GET['pno']:1;
  17. $offset = ( $page > 1 ) ? ($page-1)*$limit : 0;
  18. echo $EM_Notices;
  19. ?>
  20. <div class='em-my-bookings'>
  21. <?php if ( $bookings_count >= $limit ) : ?>
  22. <div class='tablenav'>
  23. <?php
  24. if ( $bookings_count >= $limit ) {
  25. $link = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing
  26. $bookings_nav = em_paginate( $link, $bookings_count, $limit, $page);
  27. echo $bookings_nav;
  28. }
  29. ?>
  30. <div class="clear"></div>
  31. </div>
  32. <?php endif; ?>
  33. <div class="clear"></div>
  34. <?php if( $bookings_count > 0 ): ?>
  35. <div class='table-wrap'>
  36. <table id='dbem-bookings-table' class='widefat post fixed'>
  37. <thead>
  38. <tr>
  39. <th class='manage-column' scope='col'><?php _e('Event', 'dbem'); ?></th>
  40. <th class='manage-column' scope='col'><?php _e('Date', 'dbem'); ?></th>
  41. <th class='manage-column' scope='col'><?php _e('Spaces', 'dbem'); ?></th>
  42. <th class='manage-column' scope='col'><?php _e('Attendees', 'dbem'); ?></th>
  43. <th class='manage-column' scope='col'><?php _e('Status', 'dbem'); ?></th>
  44. <th class='manage-column' scope='col'>&nbsp;</th>
  45. </tr>
  46. </thead>
  47. <tbody>
  48. <?php
  49. $rowno = 0;
  50. $event_count = 0;
  51. $nonce = wp_create_nonce('booking_cancel');
  52. foreach ($EM_Bookings as $EM_Booking) {
  53. /* @var $EM_Booking EM_Booking */
  54. $EM_Event = $EM_Booking->get_event();
  55. if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
  56. $rowno++;
  57. ?>
  58. <tr>
  59. <td><?php echo $EM_Event->output("#_EVENTLINK"); ?></td>
  60. <td><?php echo date_i18n( get_option('dbem_date_format'), $EM_Event->start ); ?></td>
  61. <td><?php echo $EM_Booking->get_spaces() ?></td>
  62. <td>
  63. <?php
  64.  
  65. $attendees_list = "";
  66. $attendees = $EM_Booking->booking_meta['attendees'];
  67. if ( !empty($attendees) ){
  68.  
  69. foreach($attendees as $key => $value) {
  70. $attendees_list = "<ul style='padding-left:20px'>";
  71. foreach($value as $key_attendee => $value_attendee) {
  72. $attendees_list .= "<li>".$value_attendee["attendee_name"]."</li>";
  73. }
  74. $attendees_list .= "</ul>";
  75. }
  76. }
  77. echo $attendees_list;
  78.  
  79.  
  80. ?>
  81. </td>
  82. <td>
  83. <?php echo $EM_Booking->get_status(); ?>
  84. </td>
  85. <td>
  86. <?php
  87. $cancel_link = '';
  88. if( !in_array($EM_Booking->booking_status, array(2,3)) && get_option('dbem_bookings_user_cancellation') && $EM_Event->get_bookings()->has_open_time() ){
  89. $cancel_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'booking_cancel', 'booking_id'=>$EM_Booking->booking_id, '_wpnonce'=>$nonce));
  90. $cancel_link = '<a class="em-bookings-cancel" href="'.$cancel_url.'" onclick="if( !confirm(EM.booking_warning_cancel) ){ return false; }">'.__('Cancel','dbem').'</a>';
  91. }
  92. echo apply_filters('em_my_bookings_booking_actions', $cancel_link, $EM_Booking);
  93. ?>
  94. </td>
  95. </tr>
  96. <?php
  97. }
  98. do_action('em_my_bookings_booking_loop',$EM_Booking);
  99. $event_count++;
  100. }
  101. ?>
  102. </tbody>
  103. </table>
  104. </div>
  105. <?php else: ?>
  106. <?php _e('You do not have any bookings.', 'dbem'); ?>
  107. <?php endif; ?>
  108. <?php if( !empty($bookings_nav) && $bookings_count >= $limit ) : ?>
  109. <div class='tablenav'>
  110. <?php echo $bookings_nav; ?>
  111. <div class="clear"></div>
  112. </div>
  113. <?php endif; ?>
  114. </div>
  115. <?php do_action('em_template_my_bookings_footer', $EM_Bookings); ?>
  116. <?php else: ?>
  117. <p><?php echo sprintf(__('Please <a href="%s">Log In</a> to view your bookings.','dbem'),site_url('wp-login.php?redirect_to=' . urlencode(get_permalink()), 'login'))?></p>
  118. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement