try again

This commit is contained in:
2016-05-26 11:20:17 +10:00
parent 99e45f86a3
commit a9d35ca97f

View File

@@ -221,9 +221,11 @@ function _booking_manual_email_generate_tableselect() {
$options[$data->nid]['group_roles'] = $group_text; $options[$data->nid]['group_roles'] = $group_text;
} }
$values[$data->nid] = ($data->booking_payment_complete == 'Y' || $data->booking_status != 1) ? FALSE : TRUE; //$values[$data->nid] = ($data->booking_payment_complete == 'Y' || $data->booking_status != 1) ? FALSE : TRUE;
} }
return $options;
/*
return array ( return array (
'#type' => 'tableselect', '#type' => 'tableselect',
'#header' => $header, '#header' => $header,
@@ -234,6 +236,7 @@ function _booking_manual_email_generate_tableselect() {
'#prefix' => '<div id="manual-email-attendees-items">', '#prefix' => '<div id="manual-email-attendees-items">',
'#suffix' => '</div>', '#suffix' => '</div>',
); );
*/
} }
function _booking_manual_email_selecttype_dropdown_callback($form, &$form_state) { function _booking_manual_email_selecttype_dropdown_callback($form, &$form_state) {
@@ -241,17 +244,43 @@ function _booking_manual_email_selecttype_dropdown_callback($form, &$form_state)
//$courseid = $form_state['values']['courseid']; //$courseid = $form_state['values']['courseid'];
//$scheduleid = $form_state['values']['scheduleid']; //$scheduleid = $form_state['values']['scheduleid'];
$checkboxes = $form_state['values']['table']; //$checkboxes = $form_state['values']['table'];
$select_type = $form_state['values']['select-type']; $select_type = $form_state['values']['select-type'];
$new_default_values = array(); $new_default_values = array();
// generate new default values // generate new default values
// @todo use a function for this // @todo use a function for this
if ($select_type == "Unpaid") { if ($select_type == "Unpaid") {
$new_default_values = array("1814"); $new_default_values = array("1814" => TRUE);
} else { } else {
$new_default_values = array("1815"); $new_default_values = array("1815" => TRUE);
} }
// update cached options for tableselect
$cached_form = form_get_cache($form['#build_id'], $form_state);
$cached_form['table']['#options'] = _booking_manual_email_generate_options();
form_set_cache($form['#build_id'], $cached_form, $form_state);
// remove radios from tableselect
$form['new']['table']['#options'] = $options;
foreach (element_children($form['table']) as $key) {
if (is_numeric($key)) {
unset($form['table'][$key]);
}
}
// add new radios to tableselect
form_builder($form['#form_id'], $form['table'], $form_state);
// remove current value
unset($form['table']['#default_value']);
unset($form['table']['#value']);
watchdog('booking_debug', "<pre>Manual email new form table\n@info</pre>", array('@info' => print_r( $form['table'], true)));
// update the tableselect
$commands = array();
$commands[] = ajax_command_replace('#manual-email-attendees-items', drupal_render($form['table']));
return array('#type' => 'ajax', '#commands' => $commands);
//$options = laycoaches_schedule_course_form_schedule_options($courseid, $scheduleid); //$options = laycoaches_schedule_course_form_schedule_options($courseid, $scheduleid);
// update cached options for tableselect // update cached options for tableselect
@@ -259,7 +288,7 @@ function _booking_manual_email_selecttype_dropdown_callback($form, &$form_state)
//watchdog('booking_debug', "<pre>Manual email cached form\n@info</pre>", array('@info' => print_r( $cached_form, true))); //watchdog('booking_debug', "<pre>Manual email cached form\n@info</pre>", array('@info' => print_r( $cached_form, true)));
//unset old tableselect //unset old tableselect
unset($form['table']); //unset($form['table']);
// configure new tableselect based on old table select // configure new tableselect based on old table select
//$form['table'] = $cached_form['form']['table']; //$form['table'] = $cached_form['form']['table'];