From 264dcbc47571e3269404312ea41a0f8bd258fae0 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 30 Sep 2013 12:13:24 +1000 Subject: [PATCH] Change url for booking summary page Add state analytics --- booking.module | 2 +- booking.reports.inc | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/booking.module b/booking.module index be9bc6e..6d0d54c 100644 --- a/booking.module +++ b/booking.module @@ -204,7 +204,7 @@ function booking_menu() { $items['admin/booking/summary'] = array( 'title' => 'Booking Summary', 'description' => 'List people and their payments for the current event', - 'page callback' => 'booking_report_payments', + 'page callback' => 'booking_report_summary', 'access arguments' => array('access reports'), 'type' => MENU_NORMAL_ITEM, ); diff --git a/booking.reports.inc b/booking.reports.inc index e15f293..c908b6b 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -4,7 +4,7 @@ /** * List people and how much they have paid */ -function booking_report_payments() { +function booking_report_summary() { global $event; $text = ""; $output = ""; @@ -14,12 +14,31 @@ function booking_report_payments() { $total_paid = 0; $header = array('Id', 'Name', 'Email', 'Payment To Date', 'Total Payment Required'); + $rows = array(); $result = db_query("SELECT * FROM {booking_person} p WHERE p.booking_event_id = :eid", array(':eid' => $event->eid)); + //do some analysis about the people booked in + //first the summary of states + $state_header = array('State', 'Count'); + $state_rows = array(); + $state_stats = db_select('booking_person', 'p') + ->fields('p', array('booking_state')) + ->condition('p.booking_event_id', $event->eid, '=') + ->addExpression('COUNT(booking_state)', 'state_count') + ->execute(); + foreach ($state_stats as $state) { + $state_rows[] = array($state->booking_state, $state->state_count); + } + $output .= t("

Bookings by state

"); + $output .= theme('table', array('header' => $state_header, 'rows' => $state_rows)); + + + + $output .= t("

The following table presents a summary of payments that have been made for !event.

", array('!event' => $event->booking_eventname)); foreach ($result as $person) { $rows[] = array( l(t('!id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid))), @@ -38,20 +57,7 @@ function booking_report_payments() { $waiting_counter++; } -/* - return array( - 'first_para' => array( - '#type' => 'markup', - '#markup' => t("

The following table presents a summary"), - ), - 'table' => theme('table', array( - 'header' => $header, - 'rows' => $rows, - )), - );*/ - - $output .= t("

The following table presents a summary of payments that have been made for !event.

", array('!event' => $event->booking_eventname)); $output .= theme('table', array('header' => $header, 'rows' => $rows)); $output .= t("

Total of !bookedin registrations currently booked in, !waiting on waiting list, and !notpaid haven't paid.

", array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter));