Extra flight fields, improved data import function

This commit is contained in:
2014-07-27 15:13:28 +10:00
parent 215a261ce2
commit 5984437bff
5 changed files with 147 additions and 40 deletions

View File

@@ -35,22 +35,30 @@ function booking_report_summary() {
//define sorting information with the header
//as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
$header = array(
array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
array('data' => t('Name'), 'field' => 'booking_lastname'),
array('data' => t('Booking Status'), 'field' => 'booking_status'),
array('data' => t('Studygroups')),
array('data' => t('Room')),
array('data' => t('Travel')),
array('data' => t('Email'), 'field' => 'booking_email'),
array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
array('data' => t('Total Payment Required')),
array('data' => t('Fully paid?')),
array('data' => t('Refund Processed?'), 'field' => 'booking_refund_processed'),
array('data' => t('Refund Due'), 'field' => 'booking_refund_due'),
array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'),
array('data' => t('Committee?'), 'field' => 'booking_committee_member'),
);
$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');
if (variable_get('booking_enable_studygroups', 0) == 1)
{
$header[] = array('data' => t('Studygroups'));
}
if (variable_get('booking_enable_roomallocations', 0) == 1)
{
$header[] = array('data' => t('Room'));
}
$header[] = array('data' => t('Travel'));
$header[] = array('data' => t('Email'), 'field' => 'booking_email');
$header[] = array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid');
$header[] = array('data' => t('Total Payment Required'));
$header[] = array('data' => t('Fully paid?'));
$header[] = array('data' => t('Refund Processed?'), 'field' => 'booking_refund_processed');
$header[] = array('data' => t('Refund Due'), 'field' => 'booking_refund_due');
$header[] = array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required');
$header[] = array('data' => t('Committee?'), 'field' => 'booking_committee_member');
$rows = array();
$state_header = array('State', 'Count');
@@ -106,6 +114,7 @@ function booking_report_summary() {
foreach ($result as $person)
{
$this_row = array();
//$amount_owing = _booking_amount_owing($person->nid, 0, FALSE);
$amount_owing = _booking_amount_owing($person, 0, FALSE);
@@ -120,24 +129,32 @@ function booking_report_summary() {
}
//define the row for this person
$rows[] = array(
l(t('View !id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid))),
l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
t('node/!id/edit', array('!id' => $person->nid))
),
_booking_status_generate($person->booking_status),
l(t('Groups'), t('admin/booking/!id/edit-studygroup', array('!id' => $person->nid))),
l(t('Room'), t('admin/booking/!id/edit-room', array('!id' => $person->nid))),
$travel_link,
t('!email', array('!email' => $person->booking_email)),
t('!payment', array('!payment' => $person->booking_amount_paid)),
t('!payment', array('!payment' => $amount_owing == 0 ? $person->booking_total_pay_reqd : _booking_total_due($person))),
t('!fullypaid', array('!fullypaid' => $amount_owing == 0 ? 'Yes' : 'No')),
t('!reqd', array('!reqd' => $person->booking_refund_processed == 'Y' ? 'Yes' : 'No')),
t('!payment', array('!payment' => $person->booking_refund_due)),
t($person->booking_welfare_required == 'Y' ? 'Yes' : 'No'),
t($person->booking_committee_member == 'Y' ? 'Yes' : 'No'),
);
$this_row[] = l(t('View !id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid)));
$this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
t('node/!id/edit', array('!id' => $person->nid))
);
$this_row[] = _booking_status_generate($person->booking_status);
if (variable_get('booking_enable_studygroups', 0) == 1)
{
$this_row[] = l(t('Groups'), t('admin/booking/!id/edit-studygroup', array('!id' => $person->nid)));
}
if (variable_get('booking_enable_roomallocations', 0) == 1)
{
$this_row[] =l(t('Room'), t('admin/booking/!id/edit-room', array('!id' => $person->nid)));
}
$this_row[] = $travel_link;
$this_row[] = t('!email', array('!email' => $person->booking_email));
$this_row[] = t('!payment', array('!payment' => $person->booking_amount_paid));
$this_row[] = t('!payment', array('!payment' => $amount_owing == 0 ? $person->booking_total_pay_reqd : _booking_total_due($person)));
$this_row[] = t('!fullypaid', array('!fullypaid' => $amount_owing == 0 ? 'Yes' : 'No'));
$this_row[] = t('!reqd', array('!reqd' => $person->booking_refund_processed == 'Y' ? 'Yes' : 'No'));
$this_row[] = t('!payment', array('!payment' => $person->booking_refund_due));
$this_row[] = t($person->booking_welfare_required == 'Y' ? 'Yes' : 'No');
$this_row[] = t($person->booking_committee_member == 'Y' ? 'Yes' : 'No');
$rows[] = $this_row;
//add up the total paid
$total_paid += $person->booking_amount_paid;
@@ -508,6 +525,9 @@ function booking_csv_report() {
$custom_fields_to_skip = explode(";", variable_get('booking_csv_exclude_fields', ''));
$fields_to_skip = array_merge($builtin_fields_to_skip, $custom_fields_to_skip);
$datetime_fields = array('booking_outflight_origin_ts', 'booking_outflight_destination_ts', 'booking_rtrnflight_origin_ts',
'booking_rtrnflight_destination_ts', 'booking_timestamp', 'booking_flight_datetime_inbound', 'booking_flight_datetime_outbound');
//query the db
/*
$query = db_select('booking_person', 'p');
@@ -596,8 +616,8 @@ function booking_csv_report() {
}
//handle more exact dates
if ($key == 'booking_timestamp' || $key == 'booking_flight_datetime_inbound' || $key == 'booking_flight_datetime_outbound') {
$output[] = format_date($value, 'custom', 'd/m/Y H:i');
if (in_array($key, $datetime_fields)) {
$output[] = $value == 0 ? '0' : format_date($value, 'custom', 'd/m/Y H:i');
continue;
}