You are here

function appointment_calendar_settings_form in Appointment Calendar 7

Function to display form in Setting Page.

1 string reference to 'appointment_calendar_settings_form'
appointment_calendar_menu in ./appointment_calendar.module
Implements hook_menu().

File

./appointment_calendar_admin_settings.inc, line 11
Provide Configuration form for Appointment calendar.

Code

function appointment_calendar_settings_form($form, $form_state) {
  $form = array();
  global $base_url;
  $default_date = date('Y-m-d', time());
  $form['#attached']['css'] = array(
    drupal_get_path('module', 'appointment_calendar') . '/css/style.css',
  );
  $form['redirect'] = array(
    '#markup' => '<a href="' . $base_url . '/admin/config/appointment-calendar/settings/list-date">Goto Date Listing Page</a>',
  );
  $form['appointment_from_date'] = array(
    '#title' => t('Appointment From date'),
    '#type' => 'date_popup',
    '#date_format' => 'Y-m-d',
    '#date_year_range' => '0:+3',
    '#required' => TRUE,
    '#default_value' => $default_date,
    '#datepicker_options' => array(
      'minDate' => 0,
    ),
  );
  $form['appointment_to_date'] = array(
    '#title' => t('Appointment To date'),
    '#type' => 'date_popup',
    '#date_format' => 'Y-m-d',
    '#date_year_range' => '0:+3',
    '#required' => TRUE,
    '#default_value' => $default_date,
    '#datepicker_options' => array(
      'minDate' => 0,
    ),
  );
  $form['appointment_slot'] = array(
    '#type' => 'textfield',
    '#title' => 'No of Slots:',
    '#size' => 10,
    '#maxlength' => 10,
    '#required' => TRUE,
  );
  $form['appointment_fill'] = array(
    '#type' => 'button',
    '#value' => 'Fill Slots',
    '#weight' => 36,
    '#ajax' => array(
      'callback' => 'appointment_calendar_filltime_slots_callback_form',
      'wrapper' => 'time-slot-check',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );
  $no_slots = !empty($form_state['values']['appointment_slot']) ? $form_state['values']['appointment_slot'] : 0;

  // Fetching User inputted slots fields.
  $form['slots']['#prefix'] = '<div id="time-slot-check">';
  for ($i = 1; $i <= $no_slots; $i++) {
    $form['slots']['time_slot_' . $i] = array(
      '#type' => 'textfield',
      '#title' => check_plain('Time Slot ' . $i . ' :'),
      '#description' => t('Ex: 10:00-11:00, 13:00-14:00, etc.,'),
      '#prefix' => '<div class="time-slot-field-form">',
    );
    $form['slots']['time_slot_' . $i . '_capacity'] = array(
      '#type' => 'textfield',
      '#title' => check_plain('Slot ' . $i . ' Capacity'),
      '#description' => t('Only Numeric'),
      '#suffix' => '</div>',
    );
  }
  $form['slots']['#suffix'] = '</div>';
  $form['slots']['#weight'] = 39;
  if (!empty($form_state['values']['appointment_slot'])) {
    $form['slots']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
    $form['slots']['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset'),
    );
  }
  return $form;
}