function appointment_calendar_list_delete_form in Appointment Calendar 7
Implements hook_form().
1 string reference to 'appointment_calendar_list_delete_form'
- appointment_calendar_menu in ./
appointment_calendar.module - Implements hook_menu().
File
- ./
appointment_calendar_delete.inc, line 11 - Provides Delete page for selected date if there is no booked slot(s).
Code
function appointment_calendar_list_delete_form($form, $form_state) {
// Checking for Booked slots.
// If slots booked in particular date disable option for delete.
$query = drupal_get_query_parameters();
if (!empty($query['date'])) {
$date = date('Y-m-d', $query['date']);
$delete_query = db_select('field_data_appointment_date', 'ad');
$delete_query
->fields('ad', array(
'appointment_date_value',
));
$delete_query
->condition('appointment_date_value', '%' . db_like($date) . '%', 'LIKE');
$delete_result = $delete_query
->execute()
->fetchAll();
if (count($delete_result) >= 1) {
$form['date'] = array(
'#markup' => 'Unable to delete ' . $date . '. Appointment already booked in selected date<br>If you still want to delete the selected date, delete timeslots booked and retry<br> ',
);
$form['return'] = array(
'#type' => 'submit',
'#value' => t('Return'),
);
}
else {
$form['date_markup'] = array(
'#markup' => t('Are you sure to delete <b>:date</b>?<br>Note:All filled timeslots also will be deleted.<br>', array(
':date' => $date,
)),
);
$form['date'] = array(
'#type' => 'hidden',
'#value' => $query['date'],
);
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Yes'),
);
$form['no'] = array(
'#type' => 'submit',
'#value' => t('No'),
);
}
return $form;
}
}