Bugfixes for boyfriend/girlfriend id
This commit is contained in:
@@ -229,7 +229,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//add the empty element first
|
//add the empty element first
|
||||||
$partner_options[0] = '';
|
$partner_options[] = '';
|
||||||
|
|
||||||
//get a list of possible partners
|
//get a list of possible partners
|
||||||
$partners = db_query("SELECT nid, booking_firstname, booking_lastname, booking_partner_id FROM {booking_person} " .
|
$partners = db_query("SELECT nid, booking_firstname, booking_lastname, booking_partner_id FROM {booking_person} " .
|
||||||
@@ -246,6 +246,16 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
|
|||||||
'#default_value' => $data->booking_partner_id,
|
'#default_value' => $data->booking_partner_id,
|
||||||
'#options' => $partner_options,
|
'#options' => $partner_options,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//add the boyfriend/girlfriend field in here too
|
||||||
|
$form['your-details']['booking_bf_gf_nid'] = array(
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('Registration ID of Boyfriend/Girlfriend to be placed in the same discussion groups as you.'),
|
||||||
|
'#maxlength' => 15,
|
||||||
|
'#size' => 4,
|
||||||
|
'#required' => FALSE,
|
||||||
|
'#default_value' => !empty($data->booking_bf_gf_nid) ? $data->booking_bf_gf_nid : '',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1078,7 +1088,7 @@ function _booking_insert($node) {
|
|||||||
'booking_married' => $node->booking_married,
|
'booking_married' => $node->booking_married,
|
||||||
'booking_partner_name' => $node->booking_partner_name,
|
'booking_partner_name' => $node->booking_partner_name,
|
||||||
'booking_partner_id' => $node->booking_partner_id,
|
'booking_partner_id' => $node->booking_partner_id,
|
||||||
'booking_bf_gf_nid' => $node->booking_bf_gf_nid,
|
'booking_bf_gf_nid' => $node->booking_bf_gf_nid == '' ? 0 : $node->booking_bf_gf_nid,
|
||||||
'booking_room_mate1' => $node->booking_room_mate1,
|
'booking_room_mate1' => $node->booking_room_mate1,
|
||||||
'booking_room_mate2' => $node->booking_room_mate2,
|
'booking_room_mate2' => $node->booking_room_mate2,
|
||||||
'booking_shirt_size' => empty($node->booking_shirt_size) ? 'N/A' : $node->booking_shirt_size,
|
'booking_shirt_size' => empty($node->booking_shirt_size) ? 'N/A' : $node->booking_shirt_size,
|
||||||
@@ -1159,7 +1169,7 @@ function _booking_update($node) {
|
|||||||
'booking_married' => ($node->booking_married == 1 ? 'Y' : 'N'),
|
'booking_married' => ($node->booking_married == 1 ? 'Y' : 'N'),
|
||||||
'booking_partner_name' => $node->booking_partner_name,
|
'booking_partner_name' => $node->booking_partner_name,
|
||||||
'booking_partner_id' => $node->booking_partner_id,
|
'booking_partner_id' => $node->booking_partner_id,
|
||||||
'booking_bf_gf_nid' => $node->booking_bf_gf_nid,
|
'booking_bf_gf_nid' => $node->booking_bf_gf_nid == '' ? 0 : $node->booking_bf_gf_nid,
|
||||||
'booking_room_mate1' => $node->booking_room_mate1,
|
'booking_room_mate1' => $node->booking_room_mate1,
|
||||||
'booking_room_mate2' => $node->booking_room_mate2,
|
'booking_room_mate2' => $node->booking_room_mate2,
|
||||||
'booking_shirt_size' => $node->booking_shirt_size,
|
'booking_shirt_size' => $node->booking_shirt_size,
|
||||||
|
@@ -611,8 +611,10 @@ function booking_studygroups_calculate() {
|
|||||||
array('!id' => $it->key(), '!session' => $i, '!num' => $session_count[$i]['total'], '!gender' => $gender, '!age' => $age_type )
|
array('!id' => $it->key(), '!session' => $i, '!num' => $session_count[$i]['total'], '!gender' => $gender, '!age' => $age_type )
|
||||||
));
|
));
|
||||||
|
|
||||||
booking_assign_attendee_group($it->key(), $i, $gender, $age, $working_list, $session_count);
|
|
||||||
$partner_id = $current->booking_partner_id;
|
$partner_id = $current->booking_partner_id;
|
||||||
|
$bf_gf_id = $current->booking_bf_gf_nid;
|
||||||
|
|
||||||
|
booking_assign_attendee_group($it->key(), $i, $gender, $age, $working_list, $session_count);
|
||||||
|
|
||||||
//check if the attendee was married
|
//check if the attendee was married
|
||||||
if ($partner_id > 0)
|
if ($partner_id > 0)
|
||||||
@@ -621,8 +623,19 @@ function booking_studygroups_calculate() {
|
|||||||
drupal_set_message(t('Assigning spouse (id !spouse) of id !id to session !session (currently with !num people).',
|
drupal_set_message(t('Assigning spouse (id !spouse) of id !id to session !session (currently with !num people).',
|
||||||
array('!id' => $it->key(), '!session' => $i, '!spouse' => $current->booking_partner_id, '!num' => $session_count[$i]['total'])));
|
array('!id' => $it->key(), '!session' => $i, '!spouse' => $current->booking_partner_id, '!num' => $session_count[$i]['total'])));
|
||||||
|
|
||||||
booking_assign_attendee_group($partner_id, $i, $gender, $age, $working_list, $session_count);
|
booking_assign_attendee_group($partner_id, $i, $working_list[$partner_id]->booking_gender == 'M' ? 'male' : 'female',
|
||||||
|
_booking_get_age_years($working_list[$partner_id]->booking_dob), $working_list, $session_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check for boyfriend/girlfriend
|
||||||
|
if ($bf_gf_id> 0)
|
||||||
|
{
|
||||||
|
//add the spouse to the same session and mark as processed in the temporary attendee list
|
||||||
|
drupal_set_message(t('Assigning bf/gf (id !spouse) of id !id to session !session (currently with !num people).',
|
||||||
|
array('!id' => $it->key(), '!session' => $i, '!spouse' => $current->booking_bf_gf_nid, '!num' => $session_count[$i]['total'])));
|
||||||
|
|
||||||
|
booking_assign_attendee_group($partner_id, $i, $working_list[$bf_gf_id]->booking_gender == 'M' ? 'male' : 'female',
|
||||||
|
_booking_get_age_years($working_list[$bf_gf_id]->booking_dob), $working_list, $session_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,12 +80,6 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
|||||||
$booking_bf_gf_nid = '';
|
$booking_bf_gf_nid = '';
|
||||||
$booking_roommate = '';
|
$booking_roommate = '';
|
||||||
|
|
||||||
$person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id, booking_room_mate1 " .
|
|
||||||
"FROM {booking_person} " .
|
|
||||||
"WHERE nid = :nid ",
|
|
||||||
array(':nid' => $nid <> 0 ? $nid : $data->booking_person_nid))
|
|
||||||
->fetchObject();
|
|
||||||
|
|
||||||
if (!empty($node))
|
if (!empty($node))
|
||||||
{
|
{
|
||||||
$data = $node;
|
$data = $node;
|
||||||
@@ -100,6 +94,12 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
|||||||
//watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE)));
|
//watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id, booking_room_mate1 " .
|
||||||
|
"FROM {booking_person} " .
|
||||||
|
"WHERE nid = :nid ",
|
||||||
|
array(':nid' => $nid <> 0 ? $nid : $data->booking_person_nid))
|
||||||
|
->fetchObject();
|
||||||
|
|
||||||
if ($person)
|
if ($person)
|
||||||
{
|
{
|
||||||
$booking_dietary = $person->booking_dietary;
|
$booking_dietary = $person->booking_dietary;
|
||||||
@@ -254,7 +254,7 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
|||||||
'#title' => 'Special Requirements',
|
'#title' => 'Special Requirements',
|
||||||
);
|
);
|
||||||
//only show the dietary field if we're allowed to
|
//only show the dietary field if we're allowed to
|
||||||
if (variable_get('booking_enable_dietary', 0) == 1)
|
if (variable_get('booking_enable_dietary', 0) == 1 || $inserting == FALSE)
|
||||||
{
|
{
|
||||||
$form['requirements']['booking_dietary'] = array(
|
$form['requirements']['booking_dietary'] = array(
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
@@ -271,7 +271,7 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
|||||||
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : $booking_medical_conditions,
|
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : $booking_medical_conditions,
|
||||||
);
|
);
|
||||||
//only show the room mate field if we're allowed to
|
//only show the room mate field if we're allowed to
|
||||||
if (variable_get('booking_enable_roommate', 0) == 1)
|
if (variable_get('booking_enable_roommate', 0) == 1 || $inserting == FALSE)
|
||||||
{
|
{
|
||||||
$form['requirements']['booking_room_mate1'] = array(
|
$form['requirements']['booking_room_mate1'] = array(
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
@@ -420,7 +420,7 @@ function travel_load($nodes) {
|
|||||||
$query->distinct();
|
$query->distinct();
|
||||||
$query->join('booking_person','p','p.nid = t.booking_person_nid');
|
$query->join('booking_person','p','p.nid = t.booking_person_nid');
|
||||||
$query->fields('t');
|
$query->fields('t');
|
||||||
$query->fields('p', array('booking_dietary','booking_medical_conditions','booking_bf_gf_nid'));
|
$query->fields('p', array('booking_dietary','booking_medical_conditions','booking_bf_gf_nid', 'booking_room_mate1'));
|
||||||
$query->condition('tid', array_keys($nodes), 'IN');
|
$query->condition('tid', array_keys($nodes), 'IN');
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
|
|
||||||
@@ -471,6 +471,17 @@ function travel_insert($node)
|
|||||||
))
|
))
|
||||||
->condition('nid', $node->booking_person_nid)
|
->condition('nid', $node->booking_person_nid)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
//set the boyfriend/girlfriend to point to this person
|
||||||
|
if ($node->booking_bf_gf_nid <> 0)
|
||||||
|
{
|
||||||
|
db_update('booking_person')
|
||||||
|
->fields(array(
|
||||||
|
'booking_bf_gf_nid' => $node->booking_person_nid,
|
||||||
|
))
|
||||||
|
->condition('nid', $node->booking_bf_gf_nid)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function travel_update($node)
|
function travel_update($node)
|
||||||
@@ -502,11 +513,22 @@ function travel_update($node)
|
|||||||
->fields(array(
|
->fields(array(
|
||||||
'booking_dietary' => $node->booking_dietary,
|
'booking_dietary' => $node->booking_dietary,
|
||||||
'booking_medical_conditions' => $node->booking_medical_conditions,
|
'booking_medical_conditions' => $node->booking_medical_conditions,
|
||||||
'booking_bf_gf_nid' => $node->booking_bf_gf_nid,
|
'booking_bf_gf_nid' => $node->booking_bf_gf_nid == '' ? 0 : $node->booking_bf_gf_nid,
|
||||||
'booking_room_mate1' => $node->booking_room_mate1,
|
'booking_room_mate1' => $node->booking_room_mate1,
|
||||||
))
|
))
|
||||||
->condition('nid', $node->booking_person_nid)
|
->condition('nid', $node->booking_person_nid)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
//set the boyfriend/girlfriend to point to this person
|
||||||
|
if ($node->booking_bf_gf_nid <> 0)
|
||||||
|
{
|
||||||
|
db_update('booking_person')
|
||||||
|
->fields(array(
|
||||||
|
'booking_bf_gf_nid' => $node->booking_person_nid,
|
||||||
|
))
|
||||||
|
->condition('nid', $node->booking_bf_gf_nid)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function travel_delete($node)
|
function travel_delete($node)
|
||||||
|
Reference in New Issue
Block a user