function appointment_calendar_list_date_form in Appointment Calendar 7
Implements hook_form().
1 string reference to 'appointment_calendar_list_date_form'
- appointment_calendar_menu in ./
appointment_calendar.module - Implements hook_menu().
File
- ./
appointment_calendar_edit.inc, line 11 - Provides Edit page for selected date to change only slot capacity.
Code
function appointment_calendar_list_date_form($form, $form_state) {
// Date edit page.
$query = drupal_get_query_parameters();
if (!empty($query['date'])) {
global $base_url;
$form['redirect'] = array(
'#markup' => '<a href="' . $base_url . '/admin/config/appointment-calendar/settings">Goto Appointment Calendar Setting Page</a><br>',
);
$form['listredirect'] = array(
'#markup' => '<a href="' . $base_url . '/admin/config/appointment-calendar/settings/list-date">Goto Appointment Calendar Listing Page</a>',
);
$form['appointment_slot_date'] = array(
'#type' => 'textfield',
'#title' => 'Date',
'#default_value' => date('Y-m-d', $query['date']),
'#disabled' => TRUE,
);
// Fetching Slot previous capacity filled.
$capacity = appointment_calendar_slot_capacity($query['date']);
$i = 1;
// Show slots and capacity.
foreach (json_decode($capacity) as $key => $value) {
// Check if any appointment booked.
$slot_check = appointment_calendar_slot_capacity_value($key);
$form['time_slot_' . $i] = array(
'#type' => 'textfield',
'#title' => check_plain('Time Slot ' . $i . ' :'),
'#description' => t('Ex: 10:00-11:00, 13:00-14:00, etc.,'),
'#default_value' => $key,
'#prefix' => '<div class="time-slot-field-form">',
);
if ($slot_check > 0) {
$form['time_slot_' . $i]['#disabled'] = TRUE;
$form['time_slot_' . $i]['#description'] = t('<b>Slot :i </b>booked atleast once', array(
':i' => $i,
));
}
$form['time_slot_' . $i . '_capacity'] = array(
'#type' => 'textfield',
'#title' => check_plain('Slot ' . $i . ' Capacity'),
'#description' => t('Only Numeric'),
'#default_value' => $value,
'#suffix' => '</div>',
);
$i++;
}
$form['appointment_slot'] = array(
'#type' => 'textfield',
'#title' => 'No of Extra Slots:',
);
// Display Extra slots.
if (!empty($form_state['values'])) {
$extra_slots = $form_state['values']['appointment_slot'];
$extra_slots += $i - 1;
for ($j = $i; $j <= $extra_slots; $j++) {
$form['slots']['time_slot_' . $j] = array(
'#type' => 'textfield',
'#title' => check_plain('Time Slot ' . $j . ' :'),
'#description' => t('Ex: 10:00-11:00, 13:00-14:00, etc.,'),
'#default_value' => '',
'#prefix' => '<div class="time-slot-field-form">',
);
$form['slots']['time_slot_' . $j . '_capacity'] = array(
'#type' => 'textfield',
'#title' => check_plain('Slot ' . $j . ' Capacity'),
'#description' => t('Only Numeric'),
'#default_value' => '',
'#suffix' => '</div>',
);
}
$j++;
}
$form['add_more'] = array(
'#type' => 'submit',
'#value' => t('Add More Slots'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
}