function calendar_schedule_appointment_confirm_form

7.x calendar.module calendar_schedule_appointment_confirm_form($faculty_user_id)
6.x calendar.module calendar_schedule_appointment_confirm_form($faculty_user_id)

The confirmation form the user will see once they have made their schedule selections.

1 string reference to 'calendar_schedule_appointment_confirm_form'
calendar_menu in modules/calendar/calendar.module
implements hook_menu

File

modules/calendar/calendar.module, line 1748

Code

function calendar_schedule_appointment_confirm_form($faculty_user_id) {
  global $user;

  $form = array();

  fp_add_css(fp_get_module_path('calendar') . '/css/style.css');

  $faculty_user = fp_load_user($faculty_user_id);

  if (!$faculty_user || $faculty_user->is_faculty != TRUE) {
    return "<p>" . t("We're sorry! The link you followed is either invalid, or the selected user ID is not listed as a faculty/staff member at your
            insititution.") . "</p>";
  }

  $faculty_id = $faculty_user->cwid;
  $faculty_name = fp_get_faculty_name($faculty_id);

  $faculty_tz = fp_get_user_timezone($faculty_user);

  fp_set_title(t("Confirm Appointment with @name", array("@name" => $faculty_name)));

  $event_type_cid = intval($_REQUEST ['event_type_cid']);
  $content = content_load($event_type_cid);

  $date = $_REQUEST ['date'];
  $begin_hm = $_REQUEST ['begin_hm'];
  $temp = explode('-', $date);
  $year = intval($temp [0]);
  $month = intval($temp [1]);
  $day = intval($temp [2]);

  $month_year = $month . '_' . $year;


  $student_tz = fp_get_user_timezone();
  $form ['student_tz'] = array(
    'type' => 'hidden',
    'value' => $student_tz,
  );
  $form ['faculty_tz'] = array(
    'type' => 'hidden',
    'value' => $faculty_tz,
  );



  $url = fp_url("schedule-appointment/$faculty_user_id", "stage=3&event_type_cid=$content->cid&day=$day&month_year=$month_year");
  $link_back = "<a href='$url' title='Back'><i class='fa fa-arrow-circle-left'></i></a>&nbsp; &nbsp;";

  $form ['mark_top'] = array(
    'value' => "<h3>$link_back" . t("Please confirm to schedule your appointment:") . "</h3>",
  );



  $schedule_time_ts = strtotime($date . " " . $begin_hm); // currently this is in the STUDENT's TIMEZONE.  We want to convert it to UTC
  $offset = get_timezone_offset('UTC', $student_tz);
  $utc_schedule_time_ts = $schedule_time_ts - $offset;


  $form ['utc_schedule_time_ts'] = array(
    'type' => 'hidden',
    'value' => $utc_schedule_time_ts,
  );


  $formatted_date_for_student = format_date($schedule_time_ts, "pretty");

  $student_timezone_pretty = friendly_timezone($student_tz);
  if ($student_timezone_pretty) {
    $student_timezone_pretty = "(" . $student_timezone_pretty . ")";
  }


  // display all our information to the user to confirm

  $html = "";
  $html .= "<div class='confirm-schedule-appt-type'><strong>Appointment Type:</strong> $content->title</div>";
  $html .= "<div class='confirm-schedule-appt-datetime'><strong>Date & Time:</strong> $formatted_date_for_student $student_timezone_pretty</div>";


  $form ['formatted_date_for_student'] = array(
    'type' => 'hidden',
    'value' => $formatted_date_for_student,
  );

  $form ['schedule_date'] = array(
    'type' => 'hidden',
    'value' => $date,
  );

  $form ['schedule_begin_hm'] = array(
    'type' => 'hidden',
    'value' => $begin_hm,
  );

  $form ['faculty_user_id'] = array(
    'type' => 'hidden',
    'value' => $faculty_user_id,
  );

  $form ['event_type_cid'] = array(
    'type' => 'hidden',
    'value' => $event_type_cid,
  );




  $form ['mark_html'] = array(
    'value' => $html,
  );


  $name = $cwid = $email = $phone = "";

  $field_attributes = array();

  if ($user->id > 0) {
    // Meaning, the user is logged in!
    $name = $user->f_name . " " . $user->l_name;
    $cwid = $user->cwid;
    $email = $user->email;
    $phone = engagements_convert_to_pretty_phone_number(@$user->attributes ['mobile_phone']);



    $field_attributes = array("readonly" => "readonly", "class" => "readonly");

  }


  $form ['name'] = array(
    'type' => 'textfield',
    'label' => t('Your Name:'),
    'value' => $name,
    'attributes' => $field_attributes,
  );

  $form ['cwid'] = array(
    'type' => 'textfield',
    'label' => t('Your CWID:'),
    'value' => $cwid,
    'attributes' => $field_attributes,
  );

  $form ['email'] = array(
    'type' => 'textfield',
    'label' => t('Your Email:'),
    'value' => $email,
    'attributes' => $field_attributes,
  );

  $form ['phone'] = array(
    'type' => 'textfield',
    'label' => t('Your Phone:'),
    'value' => $phone,
    'attributes' => $field_attributes,
  );

  $form ['comments'] = array(
    'type' => 'textarea',
    'label' => t('Additional Comments:'),
    'description' => t("(Optional) Please enter any comments or details you'd like me to know before our meeting."),
  );




  $form ['submit_btn'] = array(
    'type' => 'submit',
    'spinner' => TRUE,
    'value' => t('Confirm Appointment & Save!'),
  );




  // Set our breadcrumbs
  $crumbs = array();
  $crumbs [] = array(
    'text' => t('Schedule Appointment with @name', array("@name" => $faculty_name)),
    'path' => "schedule-appointment/$faculty_user_id",
  );
  $crumbs [] = array(
    'text' => $content->title,
    'path' => "schedule-appointment/$faculty_user_id",
    'query' => "stage=2&event_type_cid=$content->cid",
  );
  $crumbs [] = array(
    'text' => t('Select Time'),
    'path' => "schedule-appointment/$faculty_user_id",
    'query' => "stage=3&event_type_cid=$content->cid&day=$day&month_year=$month_year",
  );


  fp_set_breadcrumbs($crumbs);


  return $form;
}