complete submit hook for variety session form
This commit is contained in:
@@ -241,76 +241,120 @@ function booking_variety_create_session_form($node, &$form_state, $create = TRUE
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//define the form for variety session configuration if we're not deleting a session
|
||||||
/*
|
if(!isset($form_state['storage']['confirm'])) {
|
||||||
$data = db_select ('booking_variety_timeslots', 'v')
|
$form[] = array (
|
||||||
->condition('v.tid', $editid, '=')
|
'first_heading' => array(
|
||||||
->fields('v')
|
'#type' => 'markup',
|
||||||
->execute()
|
'#markup' => $prefix,
|
||||||
->fetchObject();
|
),
|
||||||
*/
|
);
|
||||||
|
|
||||||
|
//add this to the form in a hidden field so we can update the right event
|
||||||
|
$form['tid'] = array (
|
||||||
|
'#type' => 'hidden',
|
||||||
|
'#value' => $timeslot_id,
|
||||||
|
);
|
||||||
|
|
||||||
//add this to the form in a hidden field so we can update the right event
|
$form['booking_variety_descrip'] = array (
|
||||||
$form['tid'] = array (
|
'#type' => 'textfield',
|
||||||
'#type' => 'hidden',
|
'#title' => t('The name of the variety session to add to this timeslot'),
|
||||||
'#value' => $timeslot_id,
|
'#size' => 60,
|
||||||
);
|
'#maxlength' => 150,
|
||||||
|
'#required' => TRUE,
|
||||||
|
'#default_value' => !empty($data->booking_variety_descrip) ? $data->booking_variety_descrip : '',
|
||||||
|
);
|
||||||
|
|
||||||
$form['booking_variety_descrip'] = array (
|
$form['booking_variety_status'] = array(
|
||||||
'#type' => 'textfield',
|
'#type' => 'checkbox',
|
||||||
'#title' => t('The name of the variety session to add to this timeslot'),
|
'#title' => t('Make this variety session active?'),
|
||||||
'#size' => 60,
|
'#default_value' => !empty($data->booking_variety_status) ? $data->booking_variety_status : '',
|
||||||
'#maxlength' => 150,
|
);
|
||||||
'#required' => TRUE,
|
|
||||||
'#default_value' => !empty($data->booking_variety_descrip) ? $data->booking_variety_descrip : '',
|
$form['booking_variety_maxsize'] = array (
|
||||||
);
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('The maximum number of people permitted in this variety session'),
|
||||||
|
'#size' => 5,
|
||||||
|
'#maxlength' => 5,
|
||||||
|
'#required' => TRUE,
|
||||||
|
'#default_value' => !empty($data->booking_variety_maxsize) ? $data->booking_variety_maxsize : '0',
|
||||||
|
);
|
||||||
|
|
||||||
$form['booking_variety_status'] = array(
|
if ($create == true) {
|
||||||
'#type' => 'checkbox',
|
$form['submit'] = array(
|
||||||
'#title' => t('Make this variety session active?'),
|
'#type' => 'submit',
|
||||||
'#default_value' => !empty($data->booking_variety_status) ? $data->booking_variety_status : '',
|
'#value' => t('Create Session'),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
$form['booking_variety_maxsize'] = array (
|
else {
|
||||||
'#type' => 'textfield',
|
$form['Update'] = array(
|
||||||
'#title' => t('The maximum number of people permitted in this variety session'),
|
'#type' => 'submit',
|
||||||
'#size' => 5,
|
'#value' => t('Update Session'),
|
||||||
'#maxlength' => 5,
|
);
|
||||||
'#required' => TRUE,
|
$form['Delete'] = array(
|
||||||
'#default_value' => !empty($data->booking_variety_maxsize) ? $data->booking_variety_maxsize : '0',
|
'#type' => 'submit',
|
||||||
);
|
'#value' => t('Delete Delete'),
|
||||||
|
);
|
||||||
$form['submit'] = array
|
}
|
||||||
(
|
return array (
|
||||||
'#type' => 'submit',
|
'form' => $form,
|
||||||
'#value' => t('Create'),
|
);
|
||||||
);
|
} //end checking for delete confirmation
|
||||||
|
else {
|
||||||
return array (
|
return confirm_form($form, "Are you sure you wish to delete variety session definition with id " . $session_id . "?",
|
||||||
'first_para' => array (
|
current_path(), NULL, "Delete Session");
|
||||||
'#type' => 'markup',
|
}
|
||||||
'#markup' => $prefix,
|
|
||||||
),
|
|
||||||
'form' => $form,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function booking_variety_create_session_form_submit($form, &$form_state) {
|
function booking_variety_create_session_form_submit($form, &$form_state) {
|
||||||
global $event;
|
global $event;
|
||||||
$values = $form_state['input'];
|
$values = $form_state['input'];
|
||||||
|
$redirect_path = "admin/config/booking/variety";
|
||||||
db_insert('booking_variety_sessions')
|
|
||||||
->fields(array(
|
//if we're deleting, add the confirmation to the form if it hasn't been defined yet
|
||||||
|
if($form_state['values']['op'] == 'Delete Session' && (!isset($form_state['storage']['confirm']))) {
|
||||||
|
//watchdog('booking_debug', "<pre>Variety session deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||||
|
$form_state['storage']['confirm'] = TRUE;
|
||||||
|
$form_state['rebuild'] = TRUE;
|
||||||
|
}
|
||||||
|
elseif ($form_state['values']['op'] == 'Delete Session') {
|
||||||
|
//delete the variety session
|
||||||
|
watchdog('booking', "Deleting variety session ID !sid", array('!sid' => $values['booking_session_id']));
|
||||||
|
|
||||||
|
db_delete('booking_variety_sessions')
|
||||||
|
->condition('vid', $values['booking_session_id'])
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
drupal_set_message('Deleted variety session id ' . $values['booking_session_id'] );
|
||||||
|
$form_state['redirect'] = $redirect_path;
|
||||||
|
}
|
||||||
|
elseif ($form_state['values']['op'] == 'Update Session') {
|
||||||
|
$result = db_update('booking_variety_sessions')
|
||||||
|
->fields(array(
|
||||||
'booking_eventid' => $event->eid,
|
'booking_eventid' => $event->eid,
|
||||||
'booking_variety_timeslot_id' => $values['tid'],
|
'booking_variety_descrip' => $values['booking_variety_descrip'],
|
||||||
|
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||||
|
'booking_variety_maxsize' => $values['booking_variety_maxsize'],
|
||||||
|
))
|
||||||
|
->condition('vid', $values['booking_session_id'] )
|
||||||
|
->execute();
|
||||||
|
drupal_set_message('Updated variety session id ' . $values['booking_session_id'] );
|
||||||
|
$form_state['redirect'] = $redirect_path;
|
||||||
|
}
|
||||||
|
elseif ($form_state['values']['op'] == 'Create Session') {
|
||||||
|
db_insert('booking_variety_sessions')
|
||||||
|
->fields(array(
|
||||||
|
'booking_eventid' => $event->eid,
|
||||||
|
'booking_variety_timeslot_id' => $values['tid'],
|
||||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||||
'booking_variety_descrip' => $values['booking_variety_descrip'],
|
'booking_variety_descrip' => $values['booking_variety_descrip'],
|
||||||
'booking_variety_maxsize' => $values['booking_variety_maxsize'],
|
'booking_variety_maxsize' => $values['booking_variety_maxsize'],
|
||||||
'booking_variety_regncount' => 0,
|
'booking_variety_regncount' => 0,
|
||||||
))
|
))
|
||||||
->execute();
|
->execute();
|
||||||
|
drupal_set_message('Created new variety session definition');
|
||||||
$form_state['redirect'] = array('admin/config/booking/variety');
|
$form_state['redirect'] = $redirect_path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user