Changed average age from now to start of event

This commit is contained in:
2013-10-02 15:57:20 +10:00
parent bb5dc7322e
commit ed2ca13ae8
2 changed files with 37 additions and 13 deletions

View File

@@ -18,12 +18,11 @@ function booking_report_summary() {
$married_count = 0;
$total_paid = 0;
$dob_total = 0;
$male_dob_total = 0;
$female_dob_total = 0;
$person_count = 0;
$average = 0;
$average_age = "";
//$year = 60 * 60 * 24 * 365.25;
$stats_attributes = array('style' => 'max-width:30%');
$stats_attributes = array('style' => 'max-width:30%');
$header = array('Id', 'Name', 'Email', 'Payment To Date', 'Total Payment Required');
$rows = array();
$state_header = array('State', 'Count');
@@ -61,9 +60,15 @@ function booking_report_summary() {
$person_count++;
if ($person->booking_gender == 'M')
{
$male_count++;
$male_dob_total += $person->booking_dob;
}
else
{
$female_count++;
$female_dob_total += $person->booking_dob;
}
if ($person->booking_baptised == 'Y')
$baptised_count++;
@@ -72,10 +77,8 @@ function booking_report_summary() {
$married_count++;
}
//calculate the average age timestamp
$average = $dob_total / $person_count;
//convert that to years
$average_age = floor((time() - $average) / (60 * 60 * 24 * 365.25));
//$average_age = floor((time() - $average) / (60 * 60 * 24 * 365.25));
//bookings by ecclesia
$query = db_select('booking_person', 'p')
@@ -113,11 +116,16 @@ function booking_report_summary() {
}
//output everything
$output .= t("<p>There are !boys males and !girls females registered. Of these, !baptised are baptised and !married are married. The average age is !average years.",
$output .= t("<h3>General Statistics</h3>");
$output .= t("<p>There are !boys males and !girls females registered. Of these, !baptised are baptised and !married are married.<br />",
array('!boys' => $male_count, '!girls' => $female_count, '!baptised' => $baptised_count, '!married' => $married_count
'!average' => $average_age));
$output .= t("Total of !bookedin registrations currently booked in, !waiting on waiting list, and !notpaid haven't paid.<br />",
array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter));
));
$output .= t("The overall average age at the start of the week will be !average. The male average age will be !maleaverage. The female average age will be !femaleaverage.<br />",
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.<br />",
array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter, '!total' => $person_count));
$output .= t("Total amount paid: $!paid</p>", array('!paid' => $total_paid));
$output .= t("<h3>Bookings by state</h3>");
$output .= theme('table', array('header' => $state_header, 'rows' => $state_rows, 'attributes' => $stats_attributes));