Advertisement
eventsmanager

custom bookingform.php

Jul 22nd, 2013
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.38 KB | None | 0 0
  1. <?php
  2. /*
  3. * This is where the booking form is generated.
  4. * For non-advanced users, It's SERIOUSLY NOT recommended you edit this form directly if avoidable, as you can change booking form settings in various less obtrusive and upgrade-safe ways:
  5. * - check your booking form options panel in the Booking Options tab in your settings.
  6. * - use CSS or jQuery to change the look of your booking forms
  7. * - edit the files in the forms/bookingform folder individually instead of this file, to make it more upgrade-safe
  8. * - hook into WP action/filters below to modify/generate information
  9. * Again, even if you're an advanced user, consider NOT editing this form and using other methods instead.
  10. */
  11.  
  12. /* @var $EM_Event EM_Event */
  13. global $EM_Notices;
  14. //count tickets and available tickets
  15. $tickets_count = count($EM_Event->get_bookings()->get_tickets()->tickets);
  16. $available_tickets_count = count($EM_Event->get_bookings()->get_available_tickets());
  17. //decide whether user can book, event is open for bookings etc.
  18. $can_book = is_user_logged_in() || (get_option('dbem_bookings_anonymous') && !is_user_logged_in());
  19. $is_open = $EM_Event->get_bookings()->is_open(); //whether there are any available tickets right now
  20. $show_tickets = true;
  21. //if user is logged out, check for member tickets that might be available, since we should ask them to log in instead of saying 'bookings closed'
  22. if( !$is_open && !is_user_logged_in() && $EM_Event->get_bookings()->is_open(true) ){
  23. $is_open = true;
  24. $can_book = false;
  25. $show_tickets = false;
  26. }
  27. ?>
  28. <div id="em-booking" class="em-booking <?php if( get_option('dbem_css_rsvp') ) echo 'css-booking'; ?>">
  29. <?php
  30. // We are firstly checking if the user has already booked a ticket at this event, if so offer a link to view their bookings.
  31. $EM_Booking = $EM_Event->get_bookings()->has_booking();
  32. ?>
  33. <?php if( is_object($EM_Booking) && !get_option('dbem_bookings_double') ): //Double bookings not allowed ?>
  34. <p>
  35. <?php echo get_option('dbem_bookings_form_msg_attending'); ?>
  36. <a href="<?php echo em_get_my_bookings_url(); ?>"><?php echo get_option('dbem_bookings_form_msg_bookings_link'); ?></a>
  37. </p>
  38. <?php elseif( !$EM_Event->rsvp ): //bookings not enabled ?>
  39. <p><?php echo get_option('dbem_bookings_form_msg_disabled'); ?></p>
  40. <?php elseif( $EM_Event->get_bookings()->get_available_spaces() <= 0 ): ?>
  41. <p><?php echo get_option('dbem_bookings_form_msg_full'); ?></p>
  42. <?php elseif( !$is_open ): //event has started ?>
  43. <p><?php echo get_option('dbem_bookings_form_msg_closed'); ?></p>
  44. <?php else: ?>
  45. <?php echo $EM_Notices; ?>
  46. <?php if( $tickets_count > 0) : ?>
  47. <?php //Tickets exist, so we show a booking form. ?>
  48. <form class="em-booking-form" name='booking-form' method='post' action='<?php echo apply_filters('em_booking_form_action_url',$_SERVER['REQUEST_URI']); ?>#em-booking'>
  49. <input type='hidden' name='action' value='booking_add'/>
  50. <input type='hidden' name='event_id' value='<?php echo $EM_Event->event_id; ?>'/>
  51. <input type='hidden' name='_wpnonce' value='<?php echo wp_create_nonce('booking_add'); ?>'/>
  52.  
  53. <?php if( $can_book ): ?>
  54. <div class='em-booking-form-details'>
  55. <?php
  56. if( $show_tickets && $available_tickets_count == 1 && !get_option('dbem_bookings_tickets_single_form') ){
  57. do_action('em_booking_form_before_tickets', $EM_Event); //do not delete
  58. //show single ticket form, only necessary to show to users able to book (or guests if enabled)
  59. $EM_Ticket = $EM_Event->get_bookings()->get_available_tickets()->get_first();
  60. em_locate_template('forms/bookingform/ticket-single.php',true, array('EM_Event'=>$EM_Event, 'EM_Ticket'=>$EM_Ticket));
  61. do_action('em_booking_form_after_tickets', $EM_Event); //do not delete
  62. }
  63. ?>
  64. <?php
  65. do_action('em_booking_form_before_user_details', $EM_Event);
  66. if( has_action('em_booking_form_custom') ){
  67. //Pro Custom Booking Form. You can create your own custom form by hooking into this action and setting the option above to true
  68. do_action('em_booking_form_custom', $EM_Event); //do not delete
  69. }else{
  70. //If you just want to modify booking form fields, you could do so here
  71. em_locate_template('forms/bookingform/booking-fields.php',true, array('EM_Event'=>$EM_Event));
  72. }
  73. do_action('em_booking_form_after_user_details', $EM_Event);
  74. ?>
  75. <?php
  76. // Tickets Form
  77. if( $show_tickets && ($can_book || get_option('dbem_bookings_tickets_show_loggedout')) && ($tickets_count > 1 || get_option('dbem_bookings_tickets_single_form')) ){ //show if more than 1 ticket, or if in forced ticket list view mode
  78. do_action('em_booking_form_before_tickets', $EM_Event); //do not delete
  79. //Show multiple tickets form to user, or single ticket list if settings enable this
  80. //If logged out, can be allowed to see this in settings witout the register form
  81. em_locate_template('forms/bookingform/tickets-list.php',true, array('EM_Event'=>$EM_Event));
  82. do_action('em_booking_form_after_tickets', $EM_Event); //do not delete
  83. $show_tickets = false;
  84. }
  85. ?>
  86. <?php do_action('em_booking_form_footer', $EM_Event); //do not delete ?>
  87. <div class="em-booking-buttons">
  88. <?php if( preg_match('/https?:\/\//',get_option('dbem_bookings_submit_button')) ): //Settings have an image url (we assume). Use it here as the button.?>
  89. <input type="image" src="<?php echo get_option('dbem_bookings_submit_button'); ?>" class="em-booking-submit" id="em-booking-submit" />
  90. <?php else: //Display normal submit button ?>
  91. <input type="submit" class="em-booking-submit" id="em-booking-submit" value="<?php echo get_option('dbem_bookings_submit_button'); ?>" />
  92. <?php endif; ?>
  93. </div>
  94. <?php do_action('em_booking_form_footer_after_buttons', $EM_Event); //do not delete ?>
  95. </div>
  96. <?php else: ?>
  97. <p class="em-booking-form-details"><?php echo get_option('dbem_booking_feedback_log_in'); ?></p>
  98. <?php endif; ?>
  99. </form>
  100. <?php
  101. if( !is_user_logged_in() && get_option('dbem_bookings_login_form') ){
  102. //User is not logged in, show login form (enabled on settings page)
  103. em_locate_template('forms/bookingform/login.php',true, array('EM_Event'=>$EM_Event));
  104. }
  105. ?>
  106. <br class="clear" style="clear:left;" />
  107. <?php endif; ?>
  108. <?php endif; ?>
  109. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement