insert variety registration if no record found already
This commit is contained in:
@@ -777,7 +777,7 @@ function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
}
|
||||
watchdog('booking_debug', "<pre>Variety session IDs from edit form:\n@info</pre>", array('@info' => print_r( $booking_variety_ids, true)));
|
||||
|
||||
// Get the previous variety session IDs and compare them
|
||||
// Get the previous variety session IDs so we can check for changes
|
||||
$person = db_query("SELECT * FROM {booking_person_view} WHERE nid = :nid",
|
||||
array(':nid' => $values['nid']))->fetchObject();
|
||||
$previous_variety_ids = drupal_json_decode($person->booking_variety_ids);
|
||||
@@ -875,14 +875,33 @@ function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
// update the session registration information for this person
|
||||
$result = db_update('booking_variety_regn')
|
||||
->fields(array(
|
||||
'booking_variety_ids' => drupal_json_encode($booking_variety_ids),
|
||||
))
|
||||
->condition('booking_person_nid', $values['nid'])
|
||||
->execute();
|
||||
watchdog('booking', "Updated variety session registration for person ID !nid", array('!nid' => $values['nid']));
|
||||
// See if this person ever had a variety session registration
|
||||
$update_or_insert_check = db_query("SELECT * FROM {booking_variety_regn} " .
|
||||
"WHERE booking_person_nid = :nid",
|
||||
array(':nid' => $values['nid'],
|
||||
))->fetchObject();
|
||||
|
||||
if (! $update_or_insert_check) {
|
||||
// create new variety session registration information for this person
|
||||
$result = db_insert('booking_variety_regn')
|
||||
->fields(array(
|
||||
'booking_person_nid' => $values['nid'],
|
||||
'booking_variety_ids' => drupal_json_encode($booking_variety_ids),
|
||||
))
|
||||
->execute();
|
||||
watchdog('booking', "Created variety session registration for person ID !nid", array('!nid' => $values['nid']));
|
||||
}
|
||||
else {
|
||||
// update the session registration information for this person
|
||||
$result = db_update('booking_variety_regn')
|
||||
->fields(array(
|
||||
'booking_variety_ids' => drupal_json_encode($booking_variety_ids),
|
||||
))
|
||||
->condition('booking_person_nid', $values['nid'])
|
||||
->execute();
|
||||
watchdog('booking', "Updated variety session registration for person ID !nid", array('!nid' => $values['nid']));
|
||||
}
|
||||
|
||||
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
|
Reference in New Issue
Block a user