Update summary by state to include only booked in or waiting list people

This commit is contained in:
2015-06-18 23:29:08 +10:00
parent 95199f788c
commit 15246d75ba

View File

@@ -58,8 +58,6 @@ function booking_report_summary() {
$header[] = array('data' => t('Refund Due'), 'field' => 'booking_refund_due'); $header[] = array('data' => t('Refund Due'), 'field' => 'booking_refund_due');
$header[] = array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'); $header[] = array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required');
$header[] = array('data' => t('Committee?'), 'field' => 'booking_committee_member'); $header[] = array('data' => t('Committee?'), 'field' => 'booking_committee_member');
$rows = array(); $rows = array();
$state_header = array('State', 'Count'); $state_header = array('State', 'Count');
$state_rows = array(); $state_rows = array();
@@ -69,8 +67,14 @@ function booking_report_summary() {
//do some analysis about the people booked in //do some analysis about the people booked in
//first the summary of states //first the summary of states
$query = db_select('booking_person', 'p') $query = db_select('booking_person', 'p')
->fields('p', array('booking_state', 'booking_country')) ->fields('p', array('booking_state', 'booking_country'));
->condition('p.booking_event_id', $event->eid, '=');
$db_or = db_or();
$db_or->condition('p.booking_status', 1, '=');
$db_or->condition('p.booking_status', 2, '=');
$db_and = db_and()->condition($db_or)->condition('p.booking_event_id', $event->eid, '=');
$query->condition($db_and);
$query->groupBy('p.booking_state'); $query->groupBy('p.booking_state');
$query->addExpression('COUNT(p.booking_state)', 'state_count'); $query->addExpression('COUNT(p.booking_state)', 'state_count');
$query->orderBy('state_count', 'DESC'); $query->orderBy('state_count', 'DESC');