user-info.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. echo '<div class="booked-scrollable">';
  3. echo '<p class="booked-title-bar"><small>'.esc_html__('Edit Appointment','booked').'</small></p>';
  4. $appt_id = ( isset($_POST['appt_id']) ? esc_html( $_POST['appt_id'] ) : false );
  5. ?><form action="" method="post" class="booked-form" id="editAppointmentForm" data-appt-id="<?php echo $appt_id; ?>"<?php if ($calendar_id): echo ' data-calendar-id="'.$calendar_id.'"'; endif; ?>><?php
  6. $calendars = get_the_terms( $appt_id, 'booked_custom_calendars' );
  7. if ( !empty($calendars) ):
  8. foreach( $calendars as $calendar ):
  9. $calendar_id = $calendar->term_id;
  10. endforeach;
  11. else:
  12. $calendar_id = false;
  13. endif;
  14. $_appt = get_post( $appt_id );
  15. $user_id = ( isset($_POST['user_id']) ? esc_html( $_POST['user_id'] ) : false );
  16. if ( $appt_id ):
  17. ?><p class="booked-calendar-name"><?php esc_html_e( 'Appointment Date/Time', 'booked' ); ?></p><?php
  18. // Appointment Information
  19. $time_format = get_option('time_format');
  20. $date_format = get_option('date_format');
  21. $timestamp = get_post_meta($appt_id, '_appointment_timestamp',true);
  22. $timeslot = get_post_meta($appt_id, '_appointment_timeslot',true);
  23. $cf_meta_value = get_post_meta($appt_id, '_cf_meta_value',true);
  24. $date_display = date_i18n($date_format,$timestamp);
  25. $day_name = date_i18n('l',$timestamp);
  26. $timeslots = explode('-',$timeslot);
  27. $time_start = date_i18n($time_format,strtotime($timeslots[0]));
  28. $time_end = date_i18n($time_format,strtotime($timeslots[1]));
  29. if ($timeslots[0] == '0000' && $timeslots[1] == '2400'):
  30. $timeslotText = esc_html__('All day','booked');
  31. else :
  32. $timeslotText = $time_start.' '.esc_html__('to','booked').' '.$time_end;
  33. endif;
  34. $year = date_i18n( 'Y', $timestamp );
  35. $month = date_i18n( 'm', $timestamp );
  36. $day = date_i18n( 'd', $timestamp );
  37. $full_date = date_i18n( 'Y-m-d', $timestamp );
  38. echo '<div class="field">';
  39. echo '<i class="booked-icon booked-icon-calendar" style="font-size:1.2em; position:relative; top:-1px;"></i>&nbsp;&nbsp;<span class="booked_appt_date-formatted">' . date_i18n( $date_format, $timestamp ) . '</span>';
  40. echo '<input type="hidden" placeholder="Date..." class="large textfield booked_appt_date" name="appt_date" value="' . date_i18n( 'Y-m-d', $timestamp ) . '">';
  41. echo '</div>';
  42. echo '<div class="field timeslots-select-field">';
  43. booked_timeslots_select( $appt_id, $year, $month, $day );
  44. echo '</div>';
  45. echo '<hr>';
  46. ?><p class="booked-calendar-name"><?php esc_html_e( 'Customer Information', 'booked' ); ?></p><?php
  47. if ( !$user_id ):
  48. $first_name = get_post_meta($appt_id, '_appointment_guest_name',true);
  49. $last_name = get_post_meta($appt_id, '_appointment_guest_surname',true);
  50. $customer_email = get_post_meta($appt_id, '_appointment_guest_email',true);
  51. else :
  52. // Customer Information
  53. $user_info = get_userdata($user_id);
  54. $first_name = booked_get_name($user_id,'first');
  55. $last_name = booked_get_name($user_id,'last');
  56. $customer_email = $user_info->user_email;
  57. $customer_phone = get_user_meta($user_id, 'booked_phone', true);
  58. endif;
  59. $name_requirements = get_option('booked_registration_name_requirements',array('require_name'));
  60. if (isset($name_requirements[0]) && $name_requirements[0] == 'require_surname'): ?>
  61. <div class="field">
  62. <input value="<?php echo $first_name; ?>" placeholder="<?php esc_html_e('First Name','booked'); ?>..." type="text" class="textfield" name="name" />
  63. <input value="<?php echo $last_name; ?>" placeholder="<?php esc_html_e('Last Name','booked'); ?>..." type="text" class="textfield" name="surname" />
  64. </div>
  65. <?php else: ?>
  66. <div class="field">
  67. <input value="<?php echo $first_name . ( $last_name ? ' ' . $last_name : '' ); ?>" placeholder="<?php esc_html_e('Name','booked'); ?>..." type="text" class="large textfield" name="name" />
  68. </div>
  69. <?php endif;
  70. if ($customer_email):
  71. ?><div class="field">
  72. <input value="<?php echo $customer_email; ?>" placeholder="<?php esc_html_e('Email Address','booked'); ?>..." type="email" class="large textfield" name="email" />
  73. </div><?php
  74. endif;
  75. if ($customer_phone):
  76. ?><div class="field">
  77. <input value="<?php echo $customer_phone; ?>" placeholder="<?php esc_html_e('Phone Number','booked'); ?>..." type="tel" class="large textfield" name="phone" />
  78. </div><?php
  79. endif;
  80. echo '<hr>';
  81. ?><p class="booked-calendar-name"><?php esc_html_e( 'Appointment Information', 'booked' ); ?></p><?php
  82. do_action('booked_before_appointment_information_admin');
  83. echo ($cf_meta_value ? '<div class="cf-meta-values">'.$cf_meta_value.'</div>' : '');
  84. do_action('booked_after_appointment_information_admin');
  85. echo '<hr>';
  86. ?><input type="hidden" name="action" value="booked_admin_edit_appt" />
  87. <input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
  88. <input type="hidden" name="appt_id" value="<?php echo $appt_id; ?>" />
  89. <input type="hidden" name="calendar_id" value="<?php echo $calendar_id; ?>" /><?php
  90. ?><div class="field">
  91. <input type="submit" class="button button-primary" value="<?php esc_html_e('Update Appointment','booked'); ?>">
  92. </div><?php
  93. endif;
  94. ?></form><?php
  95. echo '</div>';
  96. // Close button
  97. echo '<a href="#" class="close"><i class="booked-icon booked-icon-close"></i></a>';