appointment-form.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. $bookings = array();
  3. if ( ! empty( $_POST['calendars'] ) ) {
  4. $bookings = $_POST['calendars'];
  5. } else {
  6. $calendar_id = isset( $_POST['calendar_id'] ) ? intval( $_POST['calendar_id'] ) : false;
  7. $bookings[ $calendar_id ][] = array(
  8. 'date' => isset( $_POST['date'] ) ? $_POST['date'] : '',
  9. 'title' => isset( $_POST['title'] ) ? $_POST['title'] : '',
  10. 'timeslot' => isset( $_POST['timeslot'] ) ? $_POST['timeslot'] : '',
  11. 'calendar_id' => $calendar_id,
  12. );
  13. }
  14. // allow other addons to modify the appointments booking list and filter those if necessary
  15. $bookings = apply_filters( 'booked_fe_appt_form_bookings', $bookings );
  16. // this must be False, if a plugin or script has already checked it while filtering the appointments with 'booked_fe_appt_form_bookings'
  17. $check_availability = apply_filters( 'booked_fe_appt_form_check_availability', true );
  18. // count the appointments
  19. $total_appts = 0;
  20. $total_calendars = count( $bookings );
  21. foreach ( $bookings as $calendar_id => $appointments ) {
  22. $total_appts += count( $appointments );
  23. }
  24. $has_appts = ! empty( $bookings );
  25. $availability_error = esc_html__( "Sorry, someone just booked this appointment before you could. Please choose a different booking time.", "booked" );
  26. ?>
  27. <div class="booked-form booked-scrollable">
  28. <?php
  29. // If there are appointments, show the form
  30. if ( $has_appts ) {
  31. include(BOOKED_AJAX_INCLUDES_DIR . 'front/appointment-form/form.php');
  32. }
  33. // there are no available appointments
  34. // probably some of them have been already booked and removed by an add on
  35. if ( ! $has_appts ) {
  36. echo wpautop( $availability_error );
  37. }
  38. ?>
  39. </div>
  40. <?php $new_appointment_default = get_option('booked_new_appointment_default','draft'); ?>
  41. <p class="booked-title-bar"><small><?php echo ( $new_appointment_default == 'draft' ? esc_html__('Request an Appointment','booked') : esc_html__('Book an Appointment','booked') ); ?></small></p>
  42. <?php echo '<a href="#" class="close"><i class="booked-icon booked-icon-close"></i></a>';