appointment-form.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. $date = $_POST['date'];
  3. $title = isset($_POST['title']) ? $_POST['title'] : '';
  4. $timeslot = $_POST['timeslot'];
  5. $timeslot_parts = explode('-',$timeslot);
  6. $date_format = get_option('date_format');
  7. $time_format = get_option('time_format');
  8. $args = array('orderby' => 'display_name');
  9. $user_array = get_users($args);
  10. $email_required = get_option('booked_require_guest_email_address',false);
  11. $name_requirements = get_option('booked_registration_name_requirements',array('require_name'));
  12. $name_requirements = ( isset($name_requirements[0]) ? $name_requirements[0] : false );
  13. $calendar_id = (isset($_POST['calendar_id']) ? intval($_POST['calendar_id']) : false);
  14. if ($calendar_id): $calendar_obj = get_term($calendar_id,'booked_custom_calendars'); $calendar_name = $calendar_obj->name; else: $calendar_name = ''; endif;
  15. if ($timeslot_parts[0] == '0000' && $timeslot_parts[1] == '2400'):
  16. $timeslotText = esc_html__('All day','booked');
  17. else :
  18. $timeslotText = date_i18n($time_format,strtotime($timeslot_parts[0])).' &ndash; '.date_i18n($time_format,strtotime($timeslot_parts[1]));
  19. endif;
  20. ?>
  21. <div class="booked-scrollable">
  22. <p class="booked-title-bar"><small><?php esc_html_e('New Appointment','booked'); ?></small></p>
  23. <?php if ($calendar_name): ?><p class="booked-calendar-name"><?php echo $calendar_name; ?></p><?php endif; ?>
  24. <p class="name"><b><i class="booked-icon booked-icon-calendar"></i>&nbsp;&nbsp;<?php echo date_i18n($date_format, strtotime($date)); ?>&nbsp;&nbsp;&nbsp;&nbsp;<i class="booked-icon booked-icon-clock"></i>&nbsp;&nbsp;<?php echo $timeslotText; ?></b></p>
  25. <form action="" method="post" class="booked-form" id="newAppointmentForm"<?php if ($calendar_id): echo ' data-calendar-id="'.$calendar_id.'"'; endif; ?>>
  26. <input type="hidden" name="date" value="<?php echo date_i18n('Y-m-j', strtotime($date)); ?>" />
  27. <input type="hidden" name="timestamp" value="<?php echo strtotime($date.' '.$timeslot_parts[0]); ?>" />
  28. <input type="hidden" name="timeslot" value="<?php echo $timeslot; ?>" />
  29. <?php $guest_booking = (get_option('booked_booking_type','registered') == 'guest' ? true : false); ?>
  30. <div class="field">
  31. <input data-condition="customer_type" type="radio" name="customer_type" id="customer_current" value="current" checked> <label for="customer_current"><?php esc_html_e('Current Customer','booked'); ?></label>
  32. </div>
  33. <div class="field">
  34. <input data-condition="customer_type" type="radio" name="customer_type" id="customer_new" value="new"> <label for="customer_new"><?php esc_html_e('New Customer','booked'); ?></label>
  35. </div>
  36. <?php if ($guest_booking): ?>
  37. <div class="field">
  38. <input data-condition="customer_type" type="radio" name="customer_type" id="customer_guest" value="guest"> <label for="customer_guest"><?php esc_html_e('Guest','booked'); ?></label>
  39. </div>
  40. <?php endif; ?>
  41. <br>
  42. <div class="condition-block customer_type default" id="condition-current" data-condition-val="current">
  43. <div class="field">
  44. <select data-placeholder="<?php esc_html_e('Select a customer','booked'); ?>..." id="userList" name="user_id">
  45. <option></option>
  46. <?php foreach($user_array as $user): ?>
  47. <option value="<?php echo $user->ID; ?>"><?php echo booked_get_name($user->ID); ?></option>
  48. <?php endforeach; ?>
  49. </select>
  50. </div>
  51. </div>
  52. <div class="condition-block customer_type" id="condition-new" data-condition-val="new">
  53. <?php if (isset($name_requirements) && $name_requirements == 'require_surname'): ?>
  54. <div class="field">
  55. <input value="" placeholder="<?php esc_html_e('First Name','booked'); ?>..." type="text" class="textfield" name="name" />
  56. <input value="" placeholder="<?php esc_html_e('Last Name','booked'); ?>..." type="text" class="textfield" name="surname" />
  57. </div>
  58. <?php else: ?>
  59. <div class="field">
  60. <input value="" placeholder="<?php esc_html_e('Name','booked'); ?>..." type="text" class="large textfield" name="name" />
  61. </div>
  62. <?php endif; ?>
  63. <div class="field">
  64. <input value="" placeholder="<?php esc_html_e('Email Address','booked'); ?>..." type="email" class="textfield" name="email" />
  65. <input value="" placeholder="<?php esc_html_e('Choose a password','booked'); ?>..." type="password" class="textfield" name="password" />
  66. </div>
  67. </div>
  68. <?php if ($guest_booking): ?>
  69. <div class="condition-block customer_type" id="condition-guest" data-condition-val="guest">
  70. <?php if (isset($name_requirements) && $name_requirements == 'require_surname'): ?>
  71. <div class="field">
  72. <input value="" placeholder="<?php esc_html_e('First Name','booked'); ?>..." type="text" class="textfield" name="guest_name" />
  73. <input value="" placeholder="<?php esc_html_e('Last Name','booked'); ?>..." type="text" class="textfield" name="guest_surname" />
  74. </div>
  75. <?php else: ?>
  76. <div class="field">
  77. <input value="" placeholder="<?php esc_html_e('Name','booked'); ?>..." type="text" class="large textfield" name="guest_name" />
  78. </div>
  79. <?php endif; ?>
  80. <?php if ( $email_required ): ?>
  81. <div class="field">
  82. <input value="" placeholder="<?php esc_html_e('Email Address','booked'); ?>" type="email" class="large textfield" name="guest_email" />
  83. </div>
  84. <?php endif; ?>
  85. </div>
  86. <?php endif; ?>
  87. <hr>
  88. <?php booked_custom_fields($calendar_id); ?>
  89. <input type="hidden" name="booked_form_type" value="admin" />
  90. <input type="hidden" name="action" value="booked_admin_add_appt" />
  91. <input type="hidden" name="calendar_id" value="<?php echo $calendar_id; ?>" />
  92. <input type="hidden" name="title" value="<?php echo esc_attr($title); ?>" />
  93. <div class="field">
  94. <input type="submit" class="button button-primary" value="<?php esc_html_e('Create Appointment','booked'); ?>">
  95. <button class="cancel button"><?php esc_html_e('Cancel','booked'); ?></button>
  96. </div>
  97. </form>
  98. </div>
  99. <?php echo '<a href="#" class="close"><i class="booked-icon booked-icon-close"></i></a>';