From b710954bddc697e33682fe74c5ac532122716278 Mon Sep 17 00:00:00 2001
From: Nathan Coad @print_r
', array('@print_r', print_r( $result_array, TRUE)));
//delete the uploaded file
file_delete($file);
diff --git a/booking.module b/booking.module
index e7925c8..6abffb2 100644
--- a/booking.module
+++ b/booking.module
@@ -247,9 +247,9 @@ function booking_menu() {
'type' => MENU_NORMAL_ITEM,
);
- $items['admin/booking/paypal'] = array(
- 'title' => 'Booking Paypal Summary',
- 'description' => 'List paypal payments',
+ $items['admin/booking/payments'] = array(
+ 'title' => 'Booking Payment Summary',
+ 'description' => 'List all payments',
'page callback' => 'booking_report_paypal_payments',
'access arguments' => array('access reports'),
'type' => MENU_NORMAL_ITEM,
@@ -528,15 +528,6 @@ function booking_node_access($node, $op, $account) {
array('!account' => $account->uid, '!op' => $op, '!type' => $type, '@info' => var_export($account, TRUE)));
}
*/
-
- /*
- if ($op == 'view')
- return user_access('view all bookings', $account);
- if ($op == 'create')
- return user_access('create bookings', $account);
- if ($op == 'update' || $op == 'delete')
- return user_access('edit bookings', $account);
- */
}
diff --git a/booking.paypal.inc b/booking.paypal.inc
index 8a3ebec..8df513d 100644
--- a/booking.paypal.inc
+++ b/booking.paypal.inc
@@ -89,6 +89,7 @@ function booking_paypal_ipn() {
function _booking_process_payment($data) {
global $event;
$balance_payment = false;
+ $amount_owing = 0;
//TODO: verify $data['receiver_email'] matches variable_get('booking_paypal_account', '')
@@ -118,7 +119,7 @@ function _booking_process_payment($data) {
if ($duplicate_check)
{
watchdog('booking', 'Detected duplicate paypal notifications for transaction id !id, registration id !nid', array('!id' => $data['ipn_track_id'], '!nid' => $nid), WATCHDOG_ERROR);
- //return;
+ return;
}
watchdog('booking', 'Adding payment for user with node id: !id; event id: !eid', array('!id' => $nid, '!eid' => $eid));
@@ -155,6 +156,7 @@ function _booking_process_payment($data) {
->execute()
->fetchObject();
+ //check if we found a person matching this payment
if ($payment)
{
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment', array('!id' => $nid, '!eid' => $eid,
@@ -198,12 +200,11 @@ function _booking_process_payment($data) {
))
->condition('nid', $nid)
->execute();
-
- //send a notification email
//If there is no outstanding balance, send a payment complete email
+ $amount_owing = _booking_amount_owing($nid);
//if ($total >= $payment->booking_total_pay_reqd)
- if (_booking_amount_owing($nid) == 0)
+ if ($amount_owing == 0)
{
//this should always be a balance payment type email, since that tells the user that their payment is completed
_booking_registration_email($nid, TRUE);
@@ -237,16 +238,23 @@ function _booking_process_payment($data) {
->condition('nid', $payment->booking_partner_id)
->execute();
- //send an email
- _booking_registration_email($payment->booking_partner_id, $balance_payment);
+ //send an email to the spouse
+ _booking_registration_email($payment->booking_partner_id, TRUE);
}
elseif (variable_get('booking_enable_combined_pricing', 0) == 1)
{
watchdog('booking', 'Combined pricing is enabled, but this person has a partner id of !id.', array('!id' => $payment->booking_partner_id));
} //end spouse check
}
+ //if this was an initial payment we need to send a notification
+ elseif ($balance_payment == FALSE)
+ {
+ _booking_registration_email($nid, FALSE);
+ }
else //this person still has an outstanding balance so just send a confirmation email
{
+ watchdog('booking', 'This balance payment of !payment was insufficient for !id to completely pay the total outstanding of !outstanding.',
+ array('!id' => $nid, '!payment' => $data['mc_gross'], '!outstanding' => $amount_owing));
//TODO: create an email specifically for partial-balance payments
//_booking_registration_email($nid, $balance_payment);
}
diff --git a/booking.register.inc b/booking.register.inc
index 3ee0d3a..960b455 100644
--- a/booking.register.inc
+++ b/booking.register.inc
@@ -277,9 +277,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
),
),
*/
- '#title' => t('I have read and agree to the following aims and expectations.',
- array('!event' => $event->booking_eventname)
- ),
+ '#title' => token_replace(variable_get('booking_registration_aims_rules_checkbox'), booking_define_tokens()),
'#description' => token_replace(variable_get('booking_registration_aims_rules_text'), booking_define_tokens())
);
}
@@ -899,25 +897,16 @@ function booking_form_submit($form, &$form_state) {
$node->booking_passport_num = empty($values['booking_passport_num']) ? '' : $values['booking_passport_num'];
$node->booking_passport_issue_location = empty($values['booking_passport_issue_location']) ? '' : $values['booking_passport_issue_location'];
$node->booking_passport_issue_name = empty($values['booking_passport_issue_name']) ? '' : $values['booking_passport_issue_name'];
- $node->booking_passport_expiry_date = empty($values['booking_passport_expiry_date']) ? '0' : _datearray_to_ts($values['booking_passport_expiry_date']);
-
- //calculate booking_payment_id based on form choice of student or worker
- //$worker_type = db_result(db_query("SELECT pid FROM {booking_price} where booking_eventid = %d AND booking_price_descrip='%s'",
- // EVENTID, $values['booking_worker_type'] ));
+ $node->booking_passport_expiry_date = empty($values['booking_passport_expiry_date']) ? '0' : _datearray_to_ts($values['booking_passport_expiry_date']);
+
+ //payment details
$node->booking_payment_id = $values['booking_payment_id'];
+ //contact details
$node->booking_street = ucwords($values['booking_street']);
$node->booking_suburb = ucwords($values['booking_suburb']);
$node->booking_postcode = $values['booking_postcode'];
$node->booking_country = $values['booking_country'];
-
- //allow for user-entered value if the state is not already listed
- if ($values['booking_state'] == 'Other') {
- $node->booking_state = $values['booking_other_state'];
- } else {
- $node->booking_state = ucwords($values['booking_state']);
- }
-
$node->booking_phone = $values['booking_phone'];
$node->booking_mobile = $values['booking_mobile'];
$node->booking_email = strtolower($values['booking_email']);
@@ -926,7 +915,13 @@ function booking_form_submit($form, &$form_state) {
$node->booking_married = ($values['booking_married'] == 1 ? 'Y' : 'N');
$node->booking_partner_name = ucwords($values['booking_partner_name']);
$node->booking_partner_id = empty($values['booking_partner_id']) ? 0 : $values['booking_partner_id'];
-
+ //allow for user-entered value if the state is not already listed
+ if ($values['booking_state'] == 'Other') {
+ $node->booking_state = $values['booking_other_state'];
+ } else {
+ $node->booking_state = ucwords($values['booking_state']);
+ }
+
//emergency contact info
$node->booking_guardian_name = $values['booking_guardian_name'];
$node->booking_guardian_type = $values['booking_guardian_type'];
@@ -959,7 +954,6 @@ function booking_form_submit($form, &$form_state) {
$node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N');
$node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details'];
-
//potential fields for future
//$node->booking_payment_method = $payment_method;
$node->booking_room_mate1 = empty($values['booking_room_mate1']) ? '' : $values['booking_room_mate1'];
diff --git a/booking.reports.inc b/booking.reports.inc
index 0c082be..9b745c9 100644
--- a/booking.reports.inc
+++ b/booking.reports.inc
@@ -12,6 +12,7 @@ function booking_report_summary() {
$bookedin_counter = 0;
$notpaid_counter = 0;
$waiting_counter = 0;
+ $notcoming_counter = 0;
$male_count = 0;
$female_count = 0;
$baptised_count = 0;
@@ -32,12 +33,12 @@ function booking_report_summary() {
//as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
$header = array(
array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
- array('data' => t('Edit Link')),
- array('data' => t('Name'), 'field' => 'booking_lastname', 'sort' => 'asc'),
- array('data' => t('Email'), 'field' => 'booking_email', 'sort' => 'asc'),
- array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid', 'sort' => 'asc'),
- array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd', 'sort' => 'asc'),
- array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required', 'sort' => 'asc'),
+ array('data' => t('Name'), 'field' => 'booking_lastname'),
+ array('data' => t('Email'), 'field' => 'booking_email'),
+ array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
+ array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'),
+ array('data' => t('Fully paid?')),
+ array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'),
);
$rows = array();
@@ -80,21 +81,27 @@ function booking_report_summary() {
}
//more detailed summary
- //allow user-selectable sorting of columns as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
+ //allow user-selectable sorting of columns as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
$query = db_select('booking_person', 'p')
- ->fields('p')
- ->condition('p.booking_event_id', $event->eid, '=');
+ ->fields('p')
+ ->fields('pr', array('booking_price', 'booking_late_price'))
+ ->condition('p.booking_event_id', $event->eid, '=');
+ $query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id');
+
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
- $result = $table_sort->execute();
+ $result = $table_sort->execute();
foreach ($result as $person) {
$rows[] = array(
l(t('!id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid))),
- l(t('!id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))),
- t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
- t('!email', array('!email' => $person->booking_email)),
+ //l(t('!id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))),
+ l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
+ t('node/!id/edit', array('!id' => $person->nid))
+ ),
+ t('!email', array('!email' => $person->booking_email)),
t('!payment', array('!payment' => $person->booking_amount_paid)),
t('!payment', array('!payment' => $person->booking_total_pay_reqd)),
+ _booking_amount_paid($person->nid, $person) >= $person->booking_total_pay_reqd ? 'Yes' : 'No',
t($person->booking_welfare_required == 'Y' ? 'Yes' : 'No'),
);
$total_paid += $person->booking_amount_paid;
@@ -106,6 +113,8 @@ function booking_report_summary() {
$bookedin_counter++;
elseif ($person->booking_status == 2)
$waiting_counter++;
+ else
+ $notcoming_counter++;
//welfare
if ($person->booking_welfare_required == 'Y')
@@ -154,8 +163,9 @@ function booking_report_summary() {
array('!average' => _booking_avg_age($dob_total, $person_count, $event->booking_event_start), '!maleaverage' => _booking_avg_age($male_dob_total, $male_count, $event->booking_event_start),
'!femaleaverage' => _booking_avg_age($female_dob_total, $female_count, $event->booking_event_start)
));
- $output .= t("There are !bookedin registrations currently booked in, !waiting on waiting list, and !notpaid haven't paid, which comes to a total of !total people who have filled in the registration form.
There are !welfare people with special financial consideration approved. !fullypaid people have completed their payments.
",
array('!welfare' => $welfare_count, '!fullypaid' => $fullypaid_count
));
@@ -420,7 +430,8 @@ function booking_csv_report() {
*/
//pivot table based on http://anothermysqldba.blogspot.de/2013/06/pivot-tables-example-in-mysql.html
- $query = db_query("select distinct p.*, s1.booking_session_id as session1, s1.booking_is_leader as session1_leader, s1.booking_is_reserveleader as session1_reserveleader, s1.booking_is_helper as session1_helper, s2.booking_session_id as session2, s2.booking_is_leader as session2_leader, s2.booking_is_reserveleader as session2_reserveleader, s2.booking_is_helper as session2_helper, s3.booking_session_id as session3, s3.booking_is_leader as session3_leader, s3.booking_is_reserveleader as session3_reserveleader, s3.booking_is_helper as session3_helper, s4.booking_session_id as session4, s4.booking_is_leader as session4_leader, s4.booking_is_reserveleader as session4_reserveleader, s4.booking_is_helper as session4_helper, s5.booking_session_id as session5, s5.booking_is_leader as session5_leader, s5.booking_is_reserveleader as session5_reserveleader, s5.booking_is_helper as session5_helper, s6.booking_session_id as session6, s6.booking_is_leader as session6_leader, s6.booking_is_reserveleader as session6_reserveleader, s6.booking_is_helper as session6_helper from {booking_person} p
+ $query = db_query("select distinct p.*, s1.booking_session_id as session1, s1.booking_is_leader as session1_leader, s1.booking_is_reserveleader as session1_reserveleader, s1.booking_is_helper as session1_helper, s2.booking_session_id as session2, s2.booking_is_leader as session2_leader, s2.booking_is_reserveleader as session2_reserveleader, s2.booking_is_helper as session2_helper, s3.booking_session_id as session3, s3.booking_is_leader as session3_leader, s3.booking_is_reserveleader as session3_reserveleader, s3.booking_is_helper as session3_helper, s4.booking_session_id as session4, s4.booking_is_leader as session4_leader, s4.booking_is_reserveleader as session4_reserveleader, s4.booking_is_helper as session4_helper, s5.booking_session_id as session5, s5.booking_is_leader as session5_leader, s5.booking_is_reserveleader as session5_reserveleader, s5.booking_is_helper as session5_helper, s6.booking_session_id as session6, s6.booking_is_leader as session6_leader, s6.booking_is_reserveleader as session6_reserveleader, s6.booking_is_helper as session6_helper, pr.booking_price, pr.booking_price_descrip from {booking_person} p
+ inner join {booking_price} pr on p.booking_payment_id = pr.pid
left outer join {booking_studygroup_mapping} s1 on p.nid = s1.booking_node_id and s1.booking_studygroup_id = 1
left outer join {booking_studygroup_mapping} s2 on p.nid = s2.booking_node_id and s2.booking_studygroup_id = 2
left outer join {booking_studygroup_mapping} s3 on p.nid = s3.booking_node_id and s3.booking_studygroup_id = 3
diff --git a/booking.studygroups.inc b/booking.studygroups.inc
index 867b0e8..ba9eb8e 100644
--- a/booking.studygroups.inc
+++ b/booking.studygroups.inc
@@ -354,7 +354,7 @@ function booking_available_leadhelp_select_form_submit($form, &$form_state) {
* Function to correctly clone an associative array storing objects
* Taken from http://stackoverflow.com/questions/1532618/is-there-a-function-to-make-a-copy-of-a-php-array-to-another
*/
-function clone_array($copied_array) {
+function booking_clone_array($copied_array) {
return array_map(function($element) {
return (
((is_array($element))
@@ -368,8 +368,12 @@ function clone_array($copied_array) {
}, $copied_array);
}
-//taken from http://stackoverflow.com/questions/4102777/php-random-shuffle-array-maintaining-key-value
-function shuffle_assoc($list) {
+
+/**
+ * Function to randomise the ordering of an array
+ * taken from http://stackoverflow.com/questions/4102777/php-random-shuffle-array-maintaining-key-value
+ */
+function booking_shuffle_assoc($list) {
if (!is_array($list)) return $list;
$keys = array_keys($list);
@@ -381,6 +385,31 @@ function shuffle_assoc($list) {
return $random;
}
+/**
+ * Function to mark an attendee as processed for group calculations
+ * @param $input string containing passport number to be verified
+ */
+function booking_assign_attendee_group($nid, $session_id, $gender, $age, &$attendee_list, &$session_count)
+{
+ //mark this person as processed in the working list
+ $attendee_list[$nid]->processed = 1;
+ $attendee_list[$nid]->session = $session_id;
+
+ //record the category of person
+ $session_count[$session_id][$gender]++;
+ $session_count[$session_id]['total']++;
+
+ //record the age bracket
+ //$age = _booking_get_age_years($attendee_list[$nid]->booking_dob);
+
+ if ($age < 20)
+ $session_count[$session_id]['under20']++;
+ elseif($age >= 20 && $age < 25)
+ $session_count[$session_id]['20to25']++;
+ else
+ $session_count[$session_id]['over25']++;
+}
+
/**
* Function for calculating who belongs to which study group
*/
@@ -406,18 +435,31 @@ function booking_studygroups_calculate() {
//calculate the max number of attendees in a group
$firstgroup = reset($studygroups);
$limit = variable_get('booking_regn_limit','500');
- //add an extra two to the maximum size, to cater for some larger groups when the number of people doesn't divide evenly
- $max_people = (int) ($limit / $firstgroup->booking_num_group_sessions) + 2;
+ //add an extra one to the maximum size, to cater for some larger groups when the number of people doesn't divide evenly
+ $max_people = (int) ($limit / $firstgroup->booking_num_group_sessions) + 1;
//select all the attendees booked in
- /*
- $query = db_query("SELECT p.nid, p.booking_partner_id, p.booking_event_id, p.booking_status, l.booking_total_lead, l.booking_available_lead, l.booking_total_help, l.booking_available_help FROM {booking_person} p left outer join {booking_leadhelp_list} l on p.nid = l.booking_node_id WHERE p.booking_event_id = :eid AND p.booking_status = 1",
- array(':eid' => $event->eid));
- */
$query = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid",
array(':eid' => $event->eid));
- $attendees = $query->fetchAllAssoc('nid');
+ $attendees = $query->fetchAllAssoc('nid');
+ //calculate the ratios of males to females, and various age groups
+ $statistics = _booking_generate_statistics($attendees);
+ $gender_ratio = ($statistics['males'] / $statistics['females']) * ($max_people / 2);
+ //store them in a nice easy to access array
+ $maximums = array(
+ 'male' => ceil($gender_ratio),
+ 'female' => ceil($max_people - $gender_ratio),
+ 'under20' => floor(($statistics['under20'] / $limit) * ($max_people - 2)),
+ '20to25' => floor(($statistics['20to25'] / $limit) * ($max_people - 2)),
+ 'over25' => floor(($statistics['over25'] / $limit) * ($max_people - 2)),
+ );
+
+ drupal_set_message(t('Aiming for !males males, !females females in group. Made up of !20s under 20, !low20s between 20 and 25, and !high20s over 25. Total count in group is !max.',
+ array('!20s' => $maximums['under20'], '!low20s' => $maximums['20to25'], '!high20s' => $maximums['over25'],
+ '!males' => $maximums['male'], '!females' => $maximums['female'], '!max' => $max_people)
+ ));
+
//select any entries already in the mapping table
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
$group_mapping = $group_mapping_query->fetchAllAssoc('sid');
@@ -436,11 +478,12 @@ function booking_studygroups_calculate() {
$person->session = 0;
$person->is_leader = 'N';
$person->is_helper = 'N';
+ $person->is_reserveleader = 'N';
}
//watchdog('booking', "Attendee list: @info", array('@info' => var_export($attendees, TRUE)));
- //iterate over each study group (eg Monday Tuesday Wednesday etc)
+ //process each study group (eg Monday Tuesday Wednesday etc)
foreach ($studygroups as $group)
{
drupal_set_message(t('Processing study group !group with !sessions sessions.',
@@ -448,43 +491,61 @@ function booking_studygroups_calculate() {
//create a temporary copy of the attendee list to work with for this study group
$working_list = array();
- $working_list = shuffle_assoc(clone_array($attendees));
+ $working_list = booking_shuffle_assoc(booking_clone_array($attendees));
//set up the iterator
$obj = new ArrayObject( $working_list );
$it = $obj->getIterator();
//clear the array keeping track of the number of people in each session for this group
for ($i = 1; $i <= $group->booking_num_group_sessions; $i++)
- $session_count[$i] = 0;
+ {
+ $session_count[$i] = array(
+ 'total' => 0,
+ 'male' => 0,
+ 'female' => 0,
+ 'under20' => 0,
+ '20to25' => 0,
+ 'over25' => 0,
+ );
+ }
+ // $session_count[$i] = 0;
//search for the leaders and helpers for this study group
foreach ($group_mapping as $person)
{
- if ($person->booking_studygroup_id == $group->sid && ($person->booking_is_leader == 'Y' || $person->booking_is_helper == 'Y' || $person->booking_is_reserveleader == 'Y'))
+ if ($person->booking_studygroup_id == $group->sid && ($person->booking_is_leader == 'Y' || $person->booking_is_helper == 'Y' ||
+ $person->booking_is_reserveleader == 'Y'))
{
+ drupal_set_message(t('Leader/helper with id !id assigned to session !session (currently with !num people).',
+ array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
+ '!num' => $session_count[$person->booking_session_id]['total'])
+ ));
- drupal_set_message(t('Leader/helper with id !id assigned to session !session (currently with !num people).', array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id, '!num' => $session_count[$person->booking_session_id])));
- //mark a position in this session as being used
- $session_count[$person->booking_session_id]++;
- //mark this person as processed in the working list
- $working_list[$person->booking_node_id]->processed = 1;
+ //mark this position as being used
+ $age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob);
+ booking_assign_attendee_group($person->booking_node_id, $person->booking_session_id, 'male', $age, $working_list, $session_count);
- //search for a spouse
+ //get any potential spouse info
$spouse_id = $working_list[$person->booking_node_id]->booking_partner_id;
if ($spouse_id > 0)
{
- drupal_set_message(t('Spouse with id !id assigned to session !session (currently with !num people).', array('!id' => $spouse_id, '!session' => $person->booking_session_id, '!num' => $session_count[$person->booking_session_id])));
- //allocate the spouse to the same session
- $working_list[$spouse_id]->session = $person->booking_session_id;
- $working_list[$spouse_id]->processed = 1;
- $session_count[$person->booking_session_id]++;
+ drupal_set_message(t('Spouse with id !id assigned to session !session (currently with !num people).',
+ array('!id' => $spouse_id, '!session' => $person->booking_session_id,
+ '!num' => $session_count[$person->booking_session_id]['total'])
+ ));
+ //allocate the spouse to the same session
+ $age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
+ booking_assign_attendee_group($spouse_id, $person->booking_session_id, 'female', $age, $working_list, $session_count);
}
+
+ //TODO: search for a boyfriend/girlfriend
+
}
}
//watchdog('booking', "Attendee list working copy after leader/helper spouse processing: @info", array('@info' => var_export($working_list, TRUE)));
//watchdog('booking', "Attendee list session count after leader/helper spouse processing: @info", array('@info' => var_export($session_count, TRUE)));
-
+ //return;
//reset the iterator to starting position
$it->rewind();
@@ -521,49 +582,48 @@ function booking_studygroups_calculate() {
//cycle the session counter if we already reached the end
if ($i > $group->booking_num_group_sessions)
$i = 1;
-
- //check this session has room in it
- $break_condition = false;
- while ($session_count[$i] >= $max_people)
- {
- drupal_set_message(t("Session ID !id is full, moving to next session for user id !nid", array('!id' => $i, '!nid' => $it->key())));
- $i++;
- //reset the counter if we go past the end
- if ($i > $group->booking_num_group_sessions)
- {
- $i = 1;
- //make sure we don't get stuck in an infinite loop - only go past the end once
- if ($break_condition == true)
- {
- drupal_set_message(t("Ran out of sessions that aren't full to place attendees into for '!id' group.", array('!id' => $group->booking_studygroup_descrip)), 'error', FALSE);
- break;
- }
- $break_condition = true;
- }
- }
-
- //get the current attendee element
- $current = $it->current();
+
+ //get the current attendee element and their stats
+ $current = $it->current();
+ $gender = $current->booking_gender == 'M' ? 'male' : 'female';
+ $age = _booking_get_age_years($current->booking_dob);
+ if ($age < 20)
+ $age_type = 'under20';
+ elseif($age >= 20 && $age < 25)
+ $age_type = '20to25';
+ else
+ $age_type = 'over25';
+
+ //make sure this person is going to fit in with our calculated gender ratios
+ _booking_loop_carefully($session_count, $gender, $i, $maximums[$gender], $group->booking_num_group_sessions, 2);
+
+ //make sure this person is going to fit in with our calculated age ratios
+ _booking_loop_carefully($session_count, $age_type, $i, $maximums[$age_type], $group->booking_num_group_sessions, 2);
+
+ //check for maximum group size
+ _booking_loop_carefully($session_count, 'total', $i, $max_people, $group->booking_num_group_sessions, 2);
+
+
//assign this attendee to this session if unprocessed so far
if ($current->processed == 0)
{
- drupal_set_message(t('Assigning person with id !id to session !session (currently with !num people).', array('!id' => $it->key(), '!session' => $i, '!num' => $session_count[$i])));
- $current->session = $i;
- $current->processed = 1;
- $partner_id = $current->booking_partner_id;
- $session_count[$i]++;
+ drupal_set_message(t('Assigning person with id !id with gender !gender and age group !age to session !session (currently with !num people).',
+ 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;
+
//check if the attendee was married
if ($partner_id > 0)
{
//add the spouse to the same session and mark as processed in the temporary attendee list
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])));
+ 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);
- $working_list[$partner_id]->session = $i;
- $working_list[$partner_id]->processed = 1;
- $session_count[$i]++;
}
}
@@ -630,22 +690,20 @@ function booking_studygroups_calculate() {
'booking_session_id' => $person->session,
'booking_is_leader' => $person->is_leader,
'booking_is_helper' => $person->is_helper,
+ 'booking_is_reserveleader' => $person->is_reserveleader,
);
$insert_query->values($record);
}
}
- $insert_query->execute();
+ //$insert_query->execute();
-
- //watchdog('booking', "Attendee list: @info", array('@info' => var_export($session_count, TRUE)));
+ watchdog('booking', "
Attendee list:\n@info", array('@info' => print_r( $session_count, true))); //clear the arrays we've been using for this iteration unset($session_count); unset($working_list); - // - } //finished processing study groups //watchdog('booking', "Attendee list final version: @info", array('@info' => var_export($attendees, TRUE))); diff --git a/booking.tokens.inc b/booking.tokens.inc index ed5e822..1ff520a 100644 --- a/booking.tokens.inc +++ b/booking.tokens.inc @@ -20,6 +20,7 @@ function booking_tokens_admin() { "
Hi. Welcome to the booking page for [booking:eventname], God willing.
Bookings are not yet open. Please try again later.
" . "If you have any questions, please use the !contact form.
", @@ -154,6 +155,12 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text '#type' => 'textarea', '#default_value' => variable_get('default_into_regn_closed_text', $default_into_regn_closed_text), ); + $form['registration']['booking_registration_aims_rules_checkbox'] = array( + '#title' => t('The text next to the aims and rules checkbox'), + '#type' => 'textarea', + '#description' => t(''), + '#default_value' => variable_get('booking_registration_aims_rules_checkbox', $default_aims_and_rules_checkbox), + ); $form['registration']['booking_registration_aims_rules_text'] = array( '#title' => t('The aims and rules attendees must agree to'), '#type' => 'textarea', @@ -335,6 +342,12 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text '#description' => t(''), '#default_value' => variable_get('booking_email_waitinglist_text', $booking_email_waitinglist_text), ); + $form['emails']['booking_email_travel_complete_text'] = array( + '#title' => t('Email text to indicate a person has completed the travel form.'), + '#type' => 'textarea', + '#description' => t(''), + '#default_value' => variable_get('booking_email_travel_complete_text', ''), + ); $form['emails']['booking_email_paymentoutstanding_text'] = array( '#title' => t('Email text to send a person reminding them of how much they owe'), '#type' => 'textarea', diff --git a/booking.travel.inc b/booking.travel.inc index 6e89e38..06c5960 100644 --- a/booking.travel.inc +++ b/booking.travel.inc @@ -43,11 +43,6 @@ function booking_travel_page() { if ($travelform) { - /* - $output .= t("
Hi !firstname !lastname. Our records indicate you or your spouse have already completed the travel details form for !event. " .
- "Please contact us if you need change any of your travel details.