eventsmanager

Custom My Bookings Page

Apr 15th, 2013
374
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. $todays_date = date("Y-m-d");
  55. $today = strtotime($todays_date);
  56.  
  57.  
  58. if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) && ($EM_Event->start >= $today) ) {
  59. $rowno++;
  60. ?>
  61. <tr>
  62. <td><?php echo $EM_Event->output("#_EVENTLINK"); ?></td>
  63. <td><?php echo date_i18n( get_option('dbem_date_format'), $EM_Event->start ); ?></td>
  64. <td><?php echo $EM_Booking->get_spaces() ?></td>
  65. <td>
  66. <?php echo $EM_Booking->get_status(); ?>
  67. </td>
  68. <td>
  69. <?php
  70. $cancel_link = '';
  71. if( !in_array($EM_Booking->status, array(2,3)) && get_option('dbem_bookings_user_cancellation') && $EM_Event->get_bookings()->has_open_time() ){
  72. $cancel_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'booking_cancel', 'booking_id'=>$EM_Booking->booking_id, '_wpnonce'=>$nonce));
  73. $cancel_link = '<a class="em-bookings-cancel" href="'.$cancel_url.'" onclick="if( !confirm(EM.booking_warning_cancel) ){ return false; }">'.__('Cancel','dbem').'</a>';
  74. }
  75. echo apply_filters('em_my_bookings_booking_actions', $cancel_link, $EM_Booking);
  76. ?>
  77. </td>
  78. <td>
  79. <a href="#" target="_blank" class="new-window">Print
  80. <div class="ticket" style="display:none">
  81. <table border="0">
  82. <tr>
  83. <td><strong><span>Name: </span></strong><?php echo $EM_Event->output("#_EVENTNAME"); ?></td>
  84. </tr>
  85. <tr>
  86. <td><strong><span>Date/Time: </span></strong><?php echo $EM_Event->output("#_EVENTDATES").' '.$EM_Event->output("#_EVENTTIMES"); ?></td>
  87. </tr>
  88. <tr><td></td></tr>
  89. <tr><td></td></tr>
  90. <tr>
  91. <td><h4>Personal Details</h4></td>
  92. </tr>
  93. <tr>
  94. <td><strong><span>Name: </span><?php echo $EM_Booking->get_person()->get_name(); ?></td>
  95. </tr>
  96. <tr>
  97. <td><strong><span>Email: </span><?php echo $EM_Booking->get_person()->user_email; ?></td>
  98. </tr>
  99. <tr>
  100. <td><strong><span>Address: </span><?php echo wp_kses_data(get_metadata('user', $EM_Booking->get_person()->ID, 'dbem_address', true)); ?></td>
  101. </tr>
  102. <tr>
  103. <td><strong><span>Address 2: </span><?php echo wp_kses_data(get_metadata('user', $EM_Booking->get_person()->ID, 'dbem_address_2', true)); ?></td>
  104. </tr>
  105. <tr>
  106. <td><strong><span>City: </span><?php echo wp_kses_data(get_metadata('user', $EM_Booking->get_person()->ID, 'dbem_city', true)); ?></td>
  107. </tr>
  108. <tr>
  109. <td><strong><span>State: </span><?php echo wp_kses_data(get_metadata('user', $EM_Booking->get_person()->ID, 'dbem_state', true)); ?></td>
  110. </tr>
  111. <tr>
  112. <td><strong><span>Zip/Post Code: </span><?php echo wp_kses_data(get_metadata('user', $EM_Booking->get_person()->ID, 'dbem_zip', true)); ?></td>
  113. </tr>
  114. <tr>
  115. <td><strong><span>Country: </span><?php echo wp_kses_data(get_metadata('user', $EM_Booking->get_person()->ID, 'dbem_country', true)); ?></td>
  116. </tr>
  117. <tr><td></td></tr>
  118. <tr><td></td></tr>
  119. <tr>
  120. <td><h4>Booking Details</h4></td>
  121. </tr>
  122. <tr>
  123. <td>
  124. <?php if ( is_array($EM_Booking->booking_meta['booking']) ){ ?>
  125. <?php foreach( $EM_Booking->booking_meta['booking'] as $key => $value) { ?>
  126. <span><strong><?php echo $key; ?></strong></span>
  127. <?php //print_r($value); ?>
  128. <?php if ( is_array($value) ){ ?>
  129. <?php foreach( $value as $key1 => $value1) { ?>
  130. <label><?php echo $value1; ?></label>
  131. <?php } ?>
  132. <?php }else{ ?>
  133. <label><?php echo $value; ?></label>
  134. <?php } ?>
  135. <br/>
  136. <?php } ?>
  137. <?php } ?>
  138. </td>
  139. </tr>
  140. </table>
  141. </div></a>
  142. </td>
  143. </tr>
  144. <?php
  145. }
  146. do_action('em_my_bookings_booking_loop',$EM_Booking);
  147. $event_count++;
  148. }
  149. ?>
  150. </tbody>
  151. </table>
  152. </div>
  153. <?php else: ?>
  154. <?php _e('You do not have any bookings.', 'dbem'); ?>
  155. <?php endif; ?>
  156. <?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
  157. <div class='tablenav'>
  158. <?php echo $bookings_nav; ?>
  159. <div class="clear"></div>
  160. </div>
  161. <?php endif; ?>
  162. </div>
  163. <?php else: ?>
  164. <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>
  165. <?php endif; ?>
  166. <?php do_action('em_template_my_bookings_footer', $EM_Bookings); ?>
  167.  
  168.  
  169.  
  170.  
  171. <script>
  172. jQuery(function ($) {
  173.  
  174. $('a.new-window').click(function () {
  175. var btn = $(this),
  176. ticket = btn.find('.ticket').html(),
  177. recipe = window.open('','PrintWindow','width=600,height=600'),
  178. html = '<html><head><title>Print Your Ticket</title></head><body><div id="myprintticket">' + ticket + '</div></body></html>';
  179. recipe.document.open();
  180. recipe.document.write(html);
  181. recipe.document.close();
  182. return false;
  183. });
  184.  
  185. });
  186. </script>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×