Added ecclesia based stats, reformatted tables

This commit is contained in:
2013-09-30 13:00:45 +10:00
parent 264dcbc475
commit 08ec1092b9

View File

@@ -12,9 +12,9 @@ function booking_report_summary() {
$notpaid_counter = 0; $notpaid_counter = 0;
$waiting_counter = 0; $waiting_counter = 0;
$total_paid = 0; $total_paid = 0;
$stats_attributes = array('style' => 'max-width:30%');
$header = array('Id', 'Name', 'Email', 'Payment To Date', 'Total Payment Required'); $header = array('Id', 'Name', 'Email', 'Payment To Date', 'Total Payment Required');
$rows = array(); $rows = array();
$result = db_query("SELECT * FROM {booking_person} p WHERE p.booking_event_id = :eid", $result = db_query("SELECT * FROM {booking_person} p WHERE p.booking_event_id = :eid",
@@ -24,20 +24,40 @@ function booking_report_summary() {
//first the summary of states //first the summary of states
$state_header = array('State', 'Count'); $state_header = array('State', 'Count');
$state_rows = array(); $state_rows = array();
$state_stats = db_select('booking_person', 'p') $non_australia_count = 0;
->fields('p', array('booking_state')) $query = db_select('booking_person', 'p')
->condition('p.booking_event_id', $event->eid, '=') ->fields('p', array('booking_state', 'booking_country'))
->addExpression('COUNT(booking_state)', 'state_count') ->condition('p.booking_event_id', $event->eid, '=');
->execute(); $query->groupBy('p.booking_state');
$query->addExpression('COUNT(p.booking_state)', 'state_count');
$state_stats = $query->execute();
foreach ($state_stats as $state) { foreach ($state_stats as $state) {
if (strcmp($state->booking_country,'Australia') == 0 )
$state_rows[] = array($state->booking_state, $state->state_count); $state_rows[] = array($state->booking_state, $state->state_count);
else
$non_australia_count += $state->state_count;
} }
$output .= t("<p>Bookings by state</p>"); //non australian states
$output .= theme('table', array('header' => $state_header, 'rows' => $state_rows)); $state_rows[] = array('International',$non_australia_count);
//bookings by ecclesia
$ecclesia_heaeder = array('Ecclesia', 'Count');
$ecclesia_rows = array();
$query = db_select('booking_person', 'p')
->fields('p', array('booking_ecclesia'))
->condition('p.booking_event_id', $event->eid, '=');
$query->groupBy('p.booking_ecclesia');
$query->addExpression('COUNT(p.booking_ecclesia)', 'ecclesia_count');
$stats = $query->execute();
foreach ($stats as $ecclesia) {
$ecclesia_rows[] = array($ecclesia->booking_ecclesia, $ecclesia->ecclesia_count);
}
//more detailed summary
$output .= t("<p>The following table presents a summary of payments that have been made for !event.</p>", array('!event' => $event->booking_eventname)); $output .= t("<p>The following table presents a summary of payments that have been made for !event.</p>", array('!event' => $event->booking_eventname));
foreach ($result as $person) { foreach ($result as $person) {
$rows[] = array( $rows[] = array(
@@ -57,7 +77,11 @@ function booking_report_summary() {
$waiting_counter++; $waiting_counter++;
} }
//output everything
$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>");
$output .= theme('table', array('header' => $ecclesia_heaeder, 'rows' => $ecclesia_rows, 'attributes' => $stats_attributes));
$output .= theme('table', array('header' => $header, 'rows' => $rows)); $output .= theme('table', array('header' => $header, 'rows' => $rows));
$output .= t("<p>Total of !bookedin registrations currently booked in, !waiting on waiting list, and !notpaid haven't paid.</p>", $output .= t("<p>Total of !bookedin registrations currently booked in, !waiting on waiting list, and !notpaid haven't paid.</p>",
array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter)); array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter));