Advertisement
eventsmanager

my-bookings template

May 20th, 2014
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 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('Status', 'dbem'); ?></th>
  43. <th class='manage-column' scope='col'>&nbsp;</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. <?php
  48. $rowno = 0;
  49. $event_count = 0;
  50. $nonce = wp_create_nonce('booking_cancel');
  51. foreach ($EM_Bookings as $EM_Booking) {
  52. /* @var $EM_Booking EM_Booking */
  53. $EM_Event = $EM_Booking->get_event();
  54. if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
  55. $rowno++;
  56. ?>
  57. <tr>
  58. <td><?php echo $EM_Event->output("#_EVENTLINK"); ?></td>
  59. <td><?php echo date_i18n( get_option('dbem_date_format'), $EM_Event->start ); ?></td>
  60. <td><?php echo $EM_Booking->get_spaces() ?></td>
  61. <td>
  62. <?php echo $EM_Booking->get_status(); ?>
  63. </td>
  64. <td>
  65. <?php
  66. $cancel_link = '';
  67. if( !in_array($EM_Booking->booking_status, array(2,3)) && get_option('dbem_bookings_user_cancellation') && $EM_Event->get_bookings()->has_open_time() ){
  68. $cancel_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'booking_cancel', 'booking_id'=>$EM_Booking->booking_id, '_wpnonce'=>$nonce));
  69. $cancel_link = '<a class="em-bookings-cancel" href="'.$cancel_url.'" onclick="if( !confirm(EM.booking_warning_cancel) ){ return false; }">'.__('Cancel','dbem').'</a>';
  70. }
  71. echo apply_filters('em_my_bookings_booking_actions', $cancel_link, $EM_Booking);
  72. ?>
  73. </td>
  74. </tr>
  75. <?php
  76. }
  77. do_action('em_my_bookings_booking_loop',$EM_Booking);
  78. $event_count++;
  79. }
  80. ?>
  81. </tbody>
  82. </table>
  83. </div>
  84. <?php else: ?>
  85. <?php _e('You do not have any bookings.', 'dbem'); ?>
  86. <?php endif; ?>
  87. <?php if( !empty($bookings_nav) && $bookings_count >= $limit ) : ?>
  88. <div class='tablenav'>
  89. <?php echo $bookings_nav; ?>
  90. <div class="clear"></div>
  91. </div>
  92. <?php endif; ?>
  93. </div>
  94. <?php do_action('em_template_my_bookings_footer', $EM_Bookings); ?>
  95. <?php else: ?>
  96. <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>
  97. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement