Advertisement
Beee

tickets-list.php

May 17th, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.39 KB | None | 0 0
  1. <?php
  2. /*
  3.  * This file generates a tabular list of tickets for the event booking forms with input values for choosing ticket spaces.
  4.  * If you want to add to this form this, you'd be better off hooking into the actions below.
  5.  */
  6. /* @var $EM_Event EM_Event */
  7. global $allowedposttags;
  8. $EM_Tickets = $EM_Event->get_bookings()->get_tickets(); //already instantiated, so should be a quick retrieval.
  9. $is_open = $EM_Event->get_bookings()->is_open(); //whether there are any available tickets right now
  10. $can_book = is_user_logged_in() || (get_option('dbem_bookings_anonymous') && !is_user_logged_in());
  11. /*
  12.  * This variable can be overriden, by hooking into the em_booking_form_tickets_cols filter and adding your collumns into this array.
  13.  * Then, you should create a em_booking_form_tickets_col_arraykey action for your collumn data, which will pass a ticket and event object.
  14.  */
  15. $collumns = $EM_Tickets->get_ticket_collumns(); // array of collumn type => title
  16.  
  17. if ( !current_user_can('access_s2member_level1') ) {
  18.     $nobooking = 1;
  19. }
  20. ?>
  21. <table class="em-tickets" cellspacing="0" cellpadding="0">
  22.     <tr>
  23.         <?php foreach($collumns as $type => $name) : ?>
  24.         <th class="em-bookings-ticket-table-<?php echo $type; ?><?php if ( $nobooking == 1 && $name == 'Spaces' ) { echo ' hide'; } ?>"><?php echo $name; ?></th>
  25.         <?php endforeach; ?>
  26.     </tr>
  27.     <?php foreach( $EM_Tickets->tickets as $EM_Ticket ) : /* @var $EM_Ticket EM_Ticket */ ?>
  28.         <?php if( $EM_Ticket->is_displayable() ): ?>
  29.             <?php do_action('em_booking_form_tickets_loop_header', $EM_Ticket); // do not delete ?>
  30.             <tr class="em-ticket" id="em-ticket-<?php echo $EM_Ticket->ticket_id; ?>">
  31.                 <?php foreach( $collumns as $type => $name ) : ?>
  32.                     <?php
  33.                     // output collumn by type, or call a custom action
  34.                     switch($type){
  35.                         case 'type':
  36.                             ?>
  37.                             <td class="em-bookings-ticket-table-type"><?php echo wp_kses_data($EM_Ticket->ticket_name); ?><?php if(!empty($EM_Ticket->ticket_description)) :?><br><span class="ticket-desc"><?php echo wp_kses($EM_Ticket->ticket_description,$allowedposttags); ?></span><?php endif; ?></td>
  38.                             <?php
  39.                             break;
  40.                         case 'price':
  41.                             global $post;
  42.                             $paypalcurr = get_post_meta($post->ID, 'Paypal currency', true); // check for custo currency
  43.                             if ($paypalcurr) { $curr = $paypalcurr; } else { $curr = '$'; }
  44.                             $ticketprice            = $EM_Ticket->get_price();
  45.                             $stripzerodprice    = str_replace("000","0",$ticketprice);
  46.  
  47.                             ?>
  48.                             <td class="em-bookings-ticket-table-price"><?php echo $curr; ?> <?php echo $stripzerodprice; ?></td>
  49.                             <?php
  50.                             break;
  51.                         case 'spaces':
  52.                             ?>
  53.                             <td class="em-bookings-ticket-table-spaces<?php if ( $nobooking == 1 ) { echo ' hide'; } ?>">
  54.                                 <?php
  55.                                     $default = !empty($_REQUEST['em_tickets'][$EM_Ticket->ticket_id]['spaces']) ? $_REQUEST['em_tickets'][$EM_Ticket->ticket_id]['spaces']:0;
  56.                                     $spaces_options = $EM_Ticket->get_spaces_options(true,$default);
  57.                                     echo ( $spaces_options ) ? $spaces_options:"<strong>".__('N/A','dbem')."</strong>";
  58.                                 ?>
  59.                             </td>
  60.                             <?php
  61.                             break;
  62.                         default:
  63.                             do_action('em_booking_form_tickets_col_'.$type, $EM_Ticket, $EM_Event);
  64.                             break;
  65.                     }
  66.                     ?>
  67.                 <?php endforeach; ?>
  68.             </tr>      
  69.             <?php do_action('em_booking_form_tickets_loop_footer', $EM_Ticket); //do not delete ?>
  70.         <?php endif; ?>
  71.     <?php endforeach; ?>
  72. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement