Change SQL queries for booking stats

This commit is contained in:
2013-10-01 12:10:00 +10:00
parent 0ff0eec9c9
commit a27def8f9e

View File

@@ -11,6 +11,10 @@ function booking_report_summary() {
$bookedin_counter = 0;
$notpaid_counter = 0;
$waiting_counter = 0;
$male_count = 0;
$female_count = 0;
$baptised_count = 0;
$married_count = 0;
$total_paid = 0;
$stats_attributes = array('style' => 'max-width:30%');
@@ -41,7 +45,25 @@ function booking_report_summary() {
//non australian states
$state_rows[] = array('International',$non_australia_count);
//general stats
$query = db_select('booking_person', 'p')
->fields('p', array('booking_baptised', 'booking_married', 'booking_gender'))
->condition('p.booking_event_id', $event->eid, '=');
$general_stats = $query->execute();
foreach ($general_stats as $person)
{
if ($person->booking_gender == 'M')
$male_count++;
else
$female_count++;
if ($person->booking_baptised == 'Y')
$baptised_count++;
if ($person->booking_married == 'Y')
$married_count++;
}
//bookings by ecclesia
$ecclesia_heaeder = array('State','Ecclesia', 'Count');
@@ -79,6 +101,8 @@ 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.</p>",
array('!boys' => $male_count, '!girls' => $female_count, '!baptised' => $baptised_count, '!married' => $married_count));
$output .= t("<p>Bookings by state</p>");
$output .= theme('table', array('header' => $state_header, 'rows' => $state_rows, 'attributes' => $stats_attributes));
$output .= t("<p>Bookings by ecclesia</p>");