bookings.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. if ( ! isset( $bookings ) ) {
  3. return;
  4. }
  5. $guest_booking = get_option( 'booked_booking_type', 'registered' ) === 'guest';
  6. $customer_type = 'current';
  7. if ( ! $is_user_logged_in ) {
  8. $customer_type = 'new';
  9. if ( $guest_booking ) {
  10. $customer_type = 'guest';
  11. }
  12. }
  13. $total_calendars = count( $bookings );
  14. $appointment_counter = 0;
  15. ?>
  16. <div class="bookings">
  17. <?php
  18. // should never come here, but just in case
  19. if ( !$total_calendars ) {
  20. esc_html_e( 'Sorry, there are no bookings available', 'booked' );
  21. return;
  22. }
  23. // When the bookings share same calendar
  24. if ( $total_calendars === 1 ):
  25. foreach ( $bookings as $calendar_id => $appointments ): ?>
  26. <input type="hidden" name="calendar_id" value="<?php echo intval($calendar_id); ?>" />
  27. <div class="booked-appointments">
  28. <?php
  29. foreach ($appointments as $appointment_key => $appointment):
  30. include( BOOKED_AJAX_INCLUDES_DIR . 'front/appointment-form/appointment.php' );
  31. $appointment_counter++;
  32. endforeach;
  33. ?>
  34. </div><?php
  35. if ( get_option('users_can_register') && !$is_user_logged_in && $customer_type != 'guest' ) {
  36. include( BOOKED_AJAX_INCLUDES_DIR . 'front/appointment-form/form-fields-registration.php' );
  37. } elseif ( !$is_user_logged_in && $customer_type == 'guest' ) {
  38. include( BOOKED_AJAX_INCLUDES_DIR . 'front/appointment-form/form-fields-guest.php' );
  39. }
  40. ?><div class="booked-calendar-fields">
  41. <?php booked_custom_fields( $calendar_id ); ?>
  42. </div><?php
  43. endforeach;
  44. endif;
  45. // When the bookings share more than one calendar. Tabbed interface to switch between the calendars.
  46. if ( $total_calendars > 1 ): ?>
  47. <div class="booked-tabs">
  48. <div class="booked-tabs-nav">
  49. <?php $i = 0; foreach ( $bookings as $calendar_id => $appointments ): ?>
  50. <?php
  51. $calendar_title = esc_html__('Unknown', 'booked');
  52. if ( ! $calendar_id ) {
  53. $calendar_title = esc_html__('Default', 'booked');
  54. }
  55. if ( $calendar_id && ( $calendar = get_term_by( 'id', $calendar_id, BOOKED_MS_TAX_CALENDAR ) ) ) {
  56. $calendar_title = $calendar->name;
  57. }
  58. ?>
  59. <span class="<?php echo $i === 0 ? 'active' : '' ?>" data-tab-cnt="booked-calendar-<?php echo intval($calendar_id) ?>" ><?php echo esc_html( $calendar_title ); ?></span>
  60. <?php $i++; ?>
  61. <?php endforeach ?>
  62. </div>
  63. <div class="booked-tabs-cnt">
  64. <?php $i = 0; foreach ( $bookings as $calendar_id => $appointments ): ?>
  65. <div class="booked-calendar-<?php echo intval($calendar_id) ?> <?php echo $i === 0 ? 'active' : '' ?>">
  66. <div class="booked-appointments">
  67. <?php
  68. foreach ($appointments as $appointment_key => $appointment) {
  69. // print the appointment details
  70. include(BOOKED_AJAX_INCLUDES_DIR . 'front/appointment-form/appointment.php');
  71. $appointment_counter++;
  72. }
  73. ?>
  74. </div>
  75. </div>
  76. <?php $i++; ?>
  77. <?php endforeach ?>
  78. </div>
  79. <?php
  80. if ( get_option('users_can_register') && !$is_user_logged_in ) {
  81. include(BOOKED_AJAX_INCLUDES_DIR . 'front/appointment-form/form-fields-registration.php');
  82. }
  83. ?>
  84. <div class="booked-tabs-cnt">
  85. <?php $i = 0; foreach ( $bookings as $calendar_id => $appointments ): ?>
  86. <div class="booked-calendar-<?php echo intval($calendar_id) ?> <?php echo $i === 0 ? 'active' : '' ?>">
  87. <div class="booked-calendar-fields">
  88. <?php booked_custom_fields( $calendar_id ); ?>
  89. </div>
  90. </div>
  91. <?php $i++; ?>
  92. <?php endforeach ?>
  93. </div>
  94. </div>
  95. <?php endif ?>
  96. </div>