Changed CSV report to include study group session data

This commit is contained in:
2014-01-30 23:16:38 +11:00
parent 50dae61740
commit 86aea0ee49
6 changed files with 42 additions and 10 deletions

View File

@@ -245,6 +245,7 @@ function booking_manual_email()
'amount_reqd' => array('data' => t('Gross Payment Required')),
'booking_status' => t('Status'),
'booking_fully_paid' => t('Fully Paid?'),
'welfare_required' => t('Welfare Required?'),
);
$result = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid",
@@ -260,6 +261,7 @@ function booking_manual_email()
'amount_reqd' => $data->booking_total_pay_reqd,
'booking_status' => _booking_status_generate($data->booking_status),
'booking_fully_paid' => $data->booking_amount_paid < $data->booking_total_pay_reqd ? 'No' : 'Yes',
'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No',
);
}

View File

@@ -250,10 +250,19 @@ function booking_update_7206() {
/**
* Add field to support welfare required flag
*
*function booking_update_7207() {
* $spec = array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE);
* db_add_field( 'booking_person', 'booking_welfare_required', $spec);
*}
*/
function booking_update_7207() {
$spec = array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE);
db_add_field( 'booking_person', 'booking_welfare_required', $spec);
/**
* Update definition for welfare required flag
*/
function booking_update_7208() {
$spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N');
db_change_field('booking_person', 'booking_welfare_required', 'booking_welfare_required', $spec);
}
/**
@@ -361,7 +370,7 @@ function booking_schema() {
'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE),
'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
'booking_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_welfare_required' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_welfare_required' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
'booking_barcode' => array('type' => 'varchar', 'length' => '8', 'not null' => FALSE),
'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE),
'booking_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE),

View File

@@ -61,6 +61,7 @@ function booking_manual_payment_admin($nid)
'amount_reqd' => array('data' => t('Gross Payment Required')),
'booking_status' => t('Status'),
'booking_fully_paid' => t('Fully Paid?'),
'welfare_required' => t('Welfare Required?'),
);
$result = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid",
@@ -76,6 +77,7 @@ function booking_manual_payment_admin($nid)
'amount_reqd' => $data->booking_total_pay_reqd,
'booking_status' => _booking_status_generate($data->booking_status),
'booking_fully_paid' => $data->booking_amount_paid < $data->booking_total_pay_reqd ? 'No' : 'Yes',
'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No',
);
}

View File

@@ -248,7 +248,7 @@ function booking_menu() {
);
$items['admin/booking/csv'] = array(
'title' => 'Booking Report',
'title' => 'Booking CSV Report',
'description' => 'Download a csv of people registered for the current event',
'page callback' => 'booking_csv_report',
'access arguments' => array('access reports'),

View File

@@ -158,6 +158,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
$form['your-details']['booking_welfare_required'] = array(
'#type' => 'checkbox',
'#title' => t('Welfare Required?'),
'#description' => t('Select to mark this attendee as requiring special financial consideration'),
'#default_value' => (!empty($data->booking_welfare_required) && $data->booking_welfare_required == 'Y') ? 1 : 0
);
@@ -1186,9 +1187,10 @@ function _booking_update($node) {
'booking_skills_language' => ($node->booking_skills_language == 1 ? 'Y' : 'N'),
'booking_skills_language_details' => $node->booking_skills_language_details,
'booking_skills_other' => ($node->booking_skills_other == 1 ? 'Y' : 'N'),
'booking_skills_other_details' => $node->booking_skills_other_details,
'booking_skills_other_details' => $node->booking_skills_other_details,
'booking_welfare_required' => ($node->booking_welfare_required == 1 ? 'Y' : 'N'),
'booking_status' => $node->booking_status,
'booking_welfare_required' => $node->booking_welfare_required,
))
->condition('nid', $node->nid)
->execute();

View File

@@ -28,6 +28,7 @@ function booking_report_summary() {
//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('Edit Link')),
array('data' => t('Name'), 'field' => 'booking_lastname', 'sort' => 'asc'),
array('data' => t('Email'), 'field' => 'booking_email', 'sort' => 'asc'),
array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid', 'sort' => 'asc'),
@@ -114,6 +115,7 @@ function booking_report_summary() {
foreach ($result as $person) {
$rows[] = array(
l(t('!id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid))),
l(t('!id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))),
t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
t('!email', array('!email' => $person->booking_email)),
t('!payment', array('!payment' => $person->booking_amount_paid)),
@@ -369,22 +371,37 @@ function booking_csv_report() {
$delimiter_esc = preg_quote($delimiter, '/');
$enclosure_esc = preg_quote($enclosure, '/');
$fields_to_skip = array('booking_payment_id', 'booking_event_id', 'booking_tempid', 'booking_shirt_size');
$fields_to_skip = array('booking_payment_id', 'booking_event_id', 'booking_tempid');
//query the db
/*
$query = db_select('booking_person', 'p');
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
$query->condition('p.booking_event_id', $event->eid)
->fields('p')
->fields('pr', array('booking_price', 'booking_price_descrip'));
$result = $query->execute()->fetchAll();
$result = $query->execute()->fetchAll();
*/
$query = db_query("select distinct p.*, s1.booking_session_id as session1, s2.booking_session_id as session2, s3.booking_session_id as session3, s4.booking_session_id as session4, s5.booking_session_id as session5, s6.booking_session_id as session6 from {booking_person} p
left outer join {booking_studygroup_mapping} s1 on p.nid = s1.booking_node_id and s1.booking_studygroup_id = 1
left outer join {booking_studygroup_mapping} s2 on p.nid = s2.booking_node_id and s2.booking_studygroup_id = 2
left outer join {booking_studygroup_mapping} s3 on p.nid = s3.booking_node_id and s3.booking_studygroup_id = 3
left outer join {booking_studygroup_mapping} s4 on p.nid = s4.booking_node_id and s4.booking_studygroup_id = 4
left outer join {booking_studygroup_mapping} s5 on p.nid = s5.booking_node_id and s5.booking_studygroup_id = 5
left outer join {booking_studygroup_mapping} s6 on p.nid = s6.booking_node_id and s6.booking_studygroup_id = 6
where p.booking_event_id = :eid ORDER BY p.nid", array('eid' => $event->eid));
$result = $query->fetchAllAssoc('nid');
watchdog('booking', "CSV raw data: @info", array('@info' => var_export($result, TRUE)));
//open the filehandle
$handle = @fopen($filename, 'w');
//write the header based on the first result
$header_array = array();
foreach ($result[0] as $key => $value)
foreach (reset($result) as $key => $value)
{
if (in_array($key, $fields_to_skip))
continue;