From 9152b533903c805e6a287b5bef5601f9dee4ba26 Mon Sep 17 00:00:00 2001
From: Nathan Coad
Date: Fri, 7 Feb 2014 00:56:51 +1100
Subject: [PATCH] Extra stats on booking summary page
---
booking.paypal.inc | 6 +++++-
booking.reports.inc | 30 +++++++++++++++++++++++++++---
booking.studygroups.inc | 25 ++++++++-----------------
3 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/booking.paypal.inc b/booking.paypal.inc
index 84d4bba..1850b62 100644
--- a/booking.paypal.inc
+++ b/booking.paypal.inc
@@ -228,7 +228,11 @@ function _booking_process_payment($data) {
->execute();
//send an email
- _booking_registration_email($payment->booking_partner_id, $balance_payment);
+ _booking_registration_email($payment->booking_partner_id, $balance_payment);
+ }
+ 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
}
else //this person still has an outstanding balance so just send a confirmation email
diff --git a/booking.reports.inc b/booking.reports.inc
index 6bf57bc..fc19275 100644
--- a/booking.reports.inc
+++ b/booking.reports.inc
@@ -21,8 +21,12 @@ function booking_report_summary() {
$male_dob_total = 0;
$female_dob_total = 0;
$person_count = 0;
+ $welfare_count = 0;
+ $fullypaid_count = 0;
$stats_attributes = array('style' => 'max-width:30%');
+
+ //TODO: add count of welfare people, and number of people fully paid
//define sorting information with the header
//as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
@@ -123,13 +127,30 @@ function booking_report_summary() {
t($person->booking_welfare_required == 'Y' ? 'Yes' : 'No'),
);
$total_paid += $person->booking_amount_paid;
-
+
+ //booking status
if ($person->booking_status == 0)
$notpaid_counter++;
elseif ($person->booking_status == 1)
$bookedin_counter++;
elseif ($person->booking_status == 2)
- $waiting_counter++;
+ $waiting_counter++;
+
+ //welfare
+ if ($person->booking_welfare_required == 'Y')
+ $welfare_count++;
+
+ //fully paid?
+ if ($person->booking_amount_paid >= $person->booking_total_pay_reqd || $person->booking_total_pay_reqd == "0.00")
+ {
+ //watchdog('booking', "Fully paid person, ID !id (!first !last)", array('!id' => $person->nid,'!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname)));
+ $fullypaid_count++;
+ }
+ elseif ($person->booking_partner_id > 0 && _booking_amount_owing($person->nid) == 0)
+ {
+ //watchdog('booking', "Fully paid married person, ID !id (!first !last)", array('!id' => $person->nid,'!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname)));
+ $fullypaid_count++;
+ }
}
//output everything
@@ -141,8 +162,11 @@ 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.
",
+ $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.
",
array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter, '!total' => $person_count));
+ $output .= t("There are !welfare people with special financial consideration approved. !fullypaid people have completed their payments.
",
+ array('!welfare' => $welfare_count, '!fullypaid' => $fullypaid_count
+ ));
$output .= t("Total amount paid: $!paid
", array('!paid' => $total_paid));
$output .= t("Bookings by state
");
$output .= theme('table', array('header' => $state_header, 'rows' => $state_rows, 'attributes' => $stats_attributes));
diff --git a/booking.studygroups.inc b/booking.studygroups.inc
index dbc2b60..b1080ba 100644
--- a/booking.studygroups.inc
+++ b/booking.studygroups.inc
@@ -223,9 +223,14 @@ function shuffle_assoc($list) {
*/
function booking_studygroups_calculate() {
global $event;
- $attendees = array();
- $working_list = array();
+ //master attendee list
+ $attendees = array();
+ //temporary working copy of attendee list
+ $working_list = array();
+ //create an array to keep track of the number of people in each session for each group
+ $session_count = array();
+
//delete from booking_studygroup_mapping;
//alter table booking_studygroup_mapping AUTO_INCREMENT=1;
@@ -240,17 +245,12 @@ function booking_studygroups_calculate() {
$limit = variable_get('booking_regn_limit','500');
//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;
-
- //drupal_set_message(t('Fitting !num people in each group.', array('!num' => $max_people)));
-
+
//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));
$attendees = $query->fetchAllAssoc('nid');
- //create an array to keep track of the number of people in each session for this group
- $session_count = array();
-
//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');
@@ -439,15 +439,6 @@ function booking_studygroups_calculate() {
//cycle the session counter if we already reached the end
if ($i > $group->booking_num_group_sessions)
$i = 1;
-
- /*
- //check we have attendees left
- if (! $it->valid() )
- {
- drupal_set_message("Ran out of attendees to process.");
- break;
- }
- */
//check this session has room in it
$break_condition = false;