function appointment_calendar_list_date_form_submit in Appointment Calendar 7
Implements hook_form_submit().
File
- ./
appointment_calendar_edit.inc, line 136 - Provides Edit page for selected date to change only slot capacity.
Code
function appointment_calendar_list_date_form_submit($form, &$form_state) {
if ($form_state['values']['op'] == t('Add More Slots')) {
$form_state['rebuild'] = TRUE;
}
if ($form_state['values']['op'] == t('Submit')) {
$date = $form_state['values']['appointment_slot_date'];
$capacity = appointment_calendar_slot_capacity(strtotime($date));
$slots = count((array) json_decode($capacity));
if (!empty($form_state['values']['appointment_slot'])) {
$slots += $form_state['values']['appointment_slot'];
}
// Fetching Timeslot and capacity values.
for ($i = 1; $i <= $slots; $i++) {
$time_slot = $form_state['values']['time_slot_' . $i];
$time_capacity = $form_state['values']['time_slot_' . $i . '_capacity'];
$slots_save[$time_slot] = $time_slot;
$slots_capacity[$time_slot] = $time_capacity;
}
// Saving date with time slots and capacity.
db_merge('appointment_date')
->key(array(
'date' => strtotime($date),
))
->fields(array(
'slot_values' => json_encode($slots_save),
'slot_capacity' => json_encode($slots_capacity),
))
->execute();
drupal_set_message(t('Changes made successfully'));
}
}