add travel summary report
This commit is contained in:
@@ -324,6 +324,14 @@ function booking_menu() {
|
|||||||
'access arguments' => array('access reports'),
|
'access arguments' => array('access reports'),
|
||||||
'type' => MENU_NORMAL_ITEM,
|
'type' => MENU_NORMAL_ITEM,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$items['admin/booking/travel'] = array(
|
||||||
|
'title' => 'Travel Summary',
|
||||||
|
'description' => "List people's travel details",
|
||||||
|
'page callback' => 'booking_report_travel',
|
||||||
|
'access arguments' => array('access reports'),
|
||||||
|
'type' => MENU_NORMAL_ITEM,
|
||||||
|
);
|
||||||
|
|
||||||
$items['admin/booking/manual-email'] = array(
|
$items['admin/booking/manual-email'] = array(
|
||||||
'title' => 'Manually Email People',
|
'title' => 'Manually Email People',
|
||||||
|
@@ -427,6 +427,84 @@ function booking_report_flight_details() {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List everyone's travel info
|
||||||
|
*/
|
||||||
|
function booking_report_travel() {
|
||||||
|
global $event;
|
||||||
|
$form = array();
|
||||||
|
$prefix = t("<h2>Travel Details</h2>");
|
||||||
|
|
||||||
|
//define sorting information with the header
|
||||||
|
//as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
|
||||||
|
$header = array();
|
||||||
|
$header[] = array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc');
|
||||||
|
$header[] = array('data' => t('Name'), 'field' => 'booking_lastname');
|
||||||
|
$header[] = array('data' => t('Booking Status'), 'field' => 'booking_status');
|
||||||
|
$header[] = array('data' => t('Transport Type'), 'field' => 'booking_transport_type');
|
||||||
|
$header[] = array('data' => t('Catching Train?'), 'field' => 'booking_transport_from_morriset_reqd');
|
||||||
|
$header[] = array('data' => t('Inbound Flight Number'), 'field' => 'booking_flightnum_inbound');
|
||||||
|
$header[] = array('data' => t('Inbound Flight Time'), 'field' => 'booking_flight_datetime_inbound');
|
||||||
|
$header[] = array('data' => t('Outbound Flight Number'), 'field' => 'booking_flightnum_outbound');
|
||||||
|
$header[] = array('data' => t('Outbound Flight Time'), 'field' => 'booking_flight_datetime_outbound');
|
||||||
|
$header[] = array('data' => t('Accommodation Before?'), 'field' => 'booking_accom_before_reqd');
|
||||||
|
$header[] = array('data' => t('Accommodation After?'), 'field' => 'booking_accom_after_reqd');
|
||||||
|
|
||||||
|
//get travel info from database
|
||||||
|
$query = db_select('booking_person', 'p');
|
||||||
|
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
||||||
|
$query->condition('p.booking_eventid', $event->eid, '=')
|
||||||
|
->fields('p')
|
||||||
|
->fields('t');
|
||||||
|
//allow user to sort columns
|
||||||
|
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||||
|
$result = $table_sort->execute();
|
||||||
|
|
||||||
|
foreach ($result as $person) {
|
||||||
|
$this_row = array();
|
||||||
|
|
||||||
|
//define the row for this person
|
||||||
|
$this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid)));
|
||||||
|
$this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
|
||||||
|
t('node/!id', array('!id' => $person->nid))
|
||||||
|
);
|
||||||
|
$this_row[] = _booking_status_generate($person->booking_status);
|
||||||
|
|
||||||
|
//calculate the travel link
|
||||||
|
if ($person->tid > 0) {
|
||||||
|
//$travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid)));
|
||||||
|
$this_row[] = t('!transport', array('!transport' => $person->booking_transport_type));
|
||||||
|
$this_row[] = t('!train', array('!train' => $person->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No'));
|
||||||
|
$this_row[] = t('!inflightnum', array('!transport' => $person->booking_flightnum_inbound));
|
||||||
|
$this_row[] = t('!inflighttime', array('!inflighttime' =>
|
||||||
|
$person->booking_flight_datetime_inbound == 0 ? '' : format_date($person->booking_flight_datetime_inbound, 'custom', 'd/m/Y H:i'));
|
||||||
|
$this_row[] = t('!outflightnum', array('!outflightnum' => $person->booking_flightnum_outbound));
|
||||||
|
$this_row[] = t('!outflighttime', array('!outflighttime' =>
|
||||||
|
$person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i'));
|
||||||
|
$this_row[] = t('!beforeaccom', array('!beforeaccom' => $person->booking_accom_before_reqd == 1 ? 'Yes' : 'No'));
|
||||||
|
$this_row[] = t('!afteraccom', array('!afteraccom' => $person->booking_accom_after_reqd == 1 ? 'Yes' : 'No'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows[] = $this_row;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array (
|
||||||
|
'first_para' => array (
|
||||||
|
'#type' => 'markup',
|
||||||
|
'#markup' => $prefix,
|
||||||
|
),
|
||||||
|
'table' => array (
|
||||||
|
'#theme' => 'table',
|
||||||
|
'#header' => $header,
|
||||||
|
'#rows' => $rows,
|
||||||
|
'#attributes' => array('id' => 'sort-table'),
|
||||||
|
//'#sticky' => FALSE,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function booking_coming_page() {
|
function booking_coming_page() {
|
||||||
global $event;
|
global $event;
|
||||||
@@ -437,21 +515,17 @@ function booking_coming_page() {
|
|||||||
$rows = array();
|
$rows = array();
|
||||||
|
|
||||||
//work out whether to include the team colour in this page
|
//work out whether to include the team colour in this page
|
||||||
if (variable_get('booking_publish_readinggroups', 0) == 1)
|
if (variable_get('booking_publish_readinggroups', 0) == 1) {
|
||||||
{
|
|
||||||
$header = array('Name', 'Team Colour', 'State');
|
$header = array('Name', 'Team Colour', 'State');
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$header = array('Name', 'State');
|
$header = array('Name', 'State');
|
||||||
}
|
}
|
||||||
|
|
||||||
//if configuration is set to show on lists even when no payment has been made, then include booking status of 0 (unpaid) or 1 (booked in)
|
//if configuration is set to show on lists even when no payment has been made, then include booking status of 0 (unpaid) or 1 (booked in)
|
||||||
//also ensure any committee members always show
|
//also ensure any committee members always show
|
||||||
if (variable_get('booking_auto_show_on_lists', 1) == 1)
|
if (variable_get('booking_auto_show_on_lists', 1) == 1) {
|
||||||
{
|
|
||||||
$or = db_or()->condition('p.booking_status', 0)->condition('p.booking_status', 1)>condition('p.booking_committee_member', 'Y');
|
$or = db_or()->condition('p.booking_status', 0)->condition('p.booking_status', 1)>condition('p.booking_committee_member', 'Y');
|
||||||
|
|
||||||
$result = db_select('booking_person', 'p')
|
$result = db_select('booking_person', 'p')
|
||||||
->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country'))
|
->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country'))
|
||||||
->condition($or)
|
->condition($or)
|
||||||
@@ -461,13 +535,10 @@ function booking_coming_page() {
|
|||||||
->orderBy('booking_lastname')
|
->orderBy('booking_lastname')
|
||||||
->orderBy('booking_firstname')
|
->orderBy('booking_firstname')
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
//payment must be made before someone will show up as booked in, but also include any committee member that might not have paid
|
//payment must be made before someone will show up as booked in, but also include any committee member that might not have paid
|
||||||
$or = db_or()->condition('p.booking_status', 1)->condition('p.booking_committee_member', 'Y');
|
$or = db_or()->condition('p.booking_status', 1)->condition('p.booking_committee_member', 'Y');
|
||||||
|
|
||||||
$result = db_select('booking_person', 'p')
|
$result = db_select('booking_person', 'p')
|
||||||
->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country'))
|
->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country'))
|
||||||
->condition($or)
|
->condition($or)
|
||||||
@@ -479,13 +550,11 @@ function booking_coming_page() {
|
|||||||
->execute();
|
->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($result as $person)
|
foreach ($result as $person) {
|
||||||
{
|
|
||||||
$state = $person->booking_country === variable_get('booking_default_country') ? $person->booking_state : $person->booking_country;
|
$state = $person->booking_country === variable_get('booking_default_country') ? $person->booking_state : $person->booking_country;
|
||||||
|
|
||||||
//if we're allowed to publish reading groups, specify them in the array element
|
//if we're allowed to publish reading groups, specify them in the array element
|
||||||
if (variable_get('booking_publish_readinggroups', 0) == 1)
|
if (variable_get('booking_publish_readinggroups', 0) == 1) {
|
||||||
{
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
t('!first !last', array('!first' => ucwords($person->booking_firstname),
|
t('!first !last', array('!first' => ucwords($person->booking_firstname),
|
||||||
'!last' => ucwords($person->booking_lastname))),
|
'!last' => ucwords($person->booking_lastname))),
|
||||||
@@ -494,8 +563,7 @@ function booking_coming_page() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
//don't publish reading group information
|
//don't publish reading group information
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
t('!first !last', array('!first' => ucwords($person->booking_firstname),
|
t('!first !last', array('!first' => ucwords($person->booking_firstname),
|
||||||
'!last' => ucwords($person->booking_lastname))),
|
'!last' => ucwords($person->booking_lastname))),
|
||||||
@@ -508,15 +576,12 @@ function booking_coming_page() {
|
|||||||
|
|
||||||
//output the results
|
//output the results
|
||||||
//check there were some bookings
|
//check there were some bookings
|
||||||
if (count($rows) > 0)
|
if (count($rows) > 0) {
|
||||||
{
|
if (count($rows) >= $booking_limit) {
|
||||||
if (count($rows) >= $booking_limit)
|
|
||||||
{
|
|
||||||
//there is a waiting list
|
//there is a waiting list
|
||||||
$output .= token_replace(variable_get('booking_whoscoming_pre_waitlist_text'), booking_define_tokens());
|
$output .= token_replace(variable_get('booking_whoscoming_pre_waitlist_text'), booking_define_tokens());
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
//there's no waiting list
|
//there's no waiting list
|
||||||
$output .= token_replace(variable_get('booking_whoscoming_pre_text'), booking_define_tokens());
|
$output .= token_replace(variable_get('booking_whoscoming_pre_text'), booking_define_tokens());
|
||||||
}
|
}
|
||||||
@@ -524,8 +589,7 @@ function booking_coming_page() {
|
|||||||
//theme the table of registrations
|
//theme the table of registrations
|
||||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
//no bookings
|
//no bookings
|
||||||
$output .= token_replace(variable_get('booking_whoscoming_pre_noregistrations_text'), booking_define_tokens());
|
$output .= token_replace(variable_get('booking_whoscoming_pre_noregistrations_text'), booking_define_tokens());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user