appointment-change-date.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. if ( !is_user_logged_in() ) {
  3. return;
  4. }
  5. $parameters = array('action', 'date', 'timeslot', 'app_id', 'app_action', 'source');
  6. foreach ($parameters as $parameter_name) {
  7. if ( !isset($_POST[$parameter_name]) || empty($_POST[$parameter_name]) ) {
  8. return;
  9. }
  10. }
  11. $app_id = intval($_POST['app_id']);
  12. $app_action = $_POST['app_action'];
  13. $source = $_POST['source'];
  14. $appt_obj = Booked_WC_Appointment::get($app_id);
  15. $calendar_id = ( isset($appt_obj->calendar->calendar_obj->term_id) ? (int)$appt_obj->calendar->calendar_obj->term_id : 0 );
  16. if (
  17. !$app_id
  18. || $app_action!=='edit'
  19. || $source!=='booked_wc_extension'
  20. ) {
  21. return;
  22. }
  23. $date = $_POST['date'];
  24. $timeslot = $_POST['timeslot'];
  25. $timeslot_parts = explode('-',$timeslot);
  26. $date_format = get_option('date_format');
  27. $time_format = get_option('time_format');
  28. if ($timeslot_parts[0] == '0000' && $timeslot_parts[1] == '2400') {
  29. $timeslotText = 'All day';
  30. } else {
  31. $timeslotText = date_i18n($time_format,strtotime($timeslot_parts[0])) . (!get_option('booked_hide_end_times') ? ' &ndash; '.date_i18n($time_format,strtotime($timeslot_parts[1])) : '');
  32. }
  33. $reached_limit = false;
  34. $input_date = date('Y-m-j', strtotime($date));
  35. $input_timestamp = strtotime($date.' '.$timeslot_parts[0]);
  36. $input_customer_type = 'current';
  37. $current_user = wp_get_current_user();
  38. $appt_timeslot = $timeslotText ? $timeslotText : '';
  39. $appt_date_name = date_i18n( $date_format, strtotime( $date ) );
  40. $user_nickname = get_user_meta($current_user->ID, 'nickname', true);
  41. ?>
  42. <div class="booked-form booked-scrollable">
  43. <p class="booked-title-bar"><small><?php echo __('Update Appointment Date', 'booked-woocommerce-payments'); ?></small></p>
  44. <form action="" method="post" id="newAppointmentForm" data-calendar-id="<?php echo $calendar_id; ?>">
  45. <input type="hidden" name="date" value="<?php echo $input_date ?>" />
  46. <input type="hidden" name="timestamp" value="<?php echo $input_timestamp ?>" />
  47. <input type="hidden" name="timeslot" value="<?php echo $timeslot; ?>" />
  48. <input type="hidden" name="customer_type" value="<?php echo $input_customer_type ?>" />
  49. <input type="hidden" name="action" value="booked_add_appt" />
  50. <input type="hidden" name="user_id" value="<?php echo $current_user->ID ?>" />
  51. <input type="hidden" name="calendar_id" value="<?php echo $calendar_id; ?>" />
  52. <input type="hidden" name="app_id" value="<?php echo $app_id ?>" />
  53. <input type="hidden" name="app_action" value="<?php echo $app_action ?>" />
  54. <input type="hidden" name="source" value="<?php echo $source ?>" />
  55. <p><?php echo sprintf(__('Please confirm that you would like to change the appointment date for %s to the following:', 'booked-woocommerce-payments'), $user_nickname); ?></p>
  56. <div class="booked-appointments">
  57. <div class="booked-appointment-details">
  58. <p class="appointment-info"><i class="booked-icon booked-icon-calendar"></i>&nbsp;&nbsp;&nbsp;<?php echo sprintf( esc_html__( '%s at %s','booked' ), $appt_date_name, $appt_timeslot ); ?></p>
  59. </div>
  60. </div>
  61. <input type="hidden" name="user_id" value="<?php echo $current_user->ID; ?>" />
  62. <div class="field">
  63. <p class="status"></p>
  64. </div>
  65. <div class="field">
  66. <?php if (!$reached_limit): ?>
  67. <input type="submit" id="submit-edit-request-appointment" class="button button-primary" value="<?php _e('Update Appointment Date', 'booked-woocommerce-payments'); ?>">
  68. <button class="cancel button"><?php _e('Cancel', 'booked-woocommerce-payments'); ?></button>
  69. <?php else: ?>
  70. <button class="cancel button"><?php _e('Okay', 'booked-woocommerce-payments'); ?></button>
  71. <?php endif; ?>
  72. </div>
  73. </form>
  74. </div>
  75. <a href="#" class="close"><i class="booked-icon booked-icon-close"></i></a>