Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active July 5, 2019 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/4a8ea5b02855ebd4d7cc720dd6112d5f to your computer and use it in GitHub Desktop.
Save joshfeck/4a8ea5b02855ebd4d7cc720dd6112d5f to your computer and use it in GitHub Desktop.
Adds a column for every datetime of the event and displays an "x" if there's a checkin for that datetime. A variation of https://github.com/eventespresso/ee-code-snippet-library/blob/master/admin/jf_ee_registration_report_add_checkin_timestamps.php
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter( 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
'espresso_add_checkin_timestamp_csv_report',
10,
2
);
function espresso_add_checkin_timestamp_csv_report( array $csv_row, $reg_db_row ) {
$checkin_rows = (array)EEM_Checkin::instance()->get_all_wpdb_results(
array(
array(
'REG_ID' => $reg_db_row['Registration.REG_ID'],
),
)
);
$checkins_for_csv_col = array();
$datetime_checkins_for_csv_col = array();
$checkin_dtt_id_array = array();
foreach ( $checkin_rows as $checkin_row ) {
$checkins_for_csv_col[] = $checkin_row['Checkin.CHK_timestamp'];
$checkin_for_dtt_id = $checkin_row['Checkin.DTT_ID'];
$checkin_for_dtt_name = \EEM_Datetime::instance()->get_var(
array(
array('DTT_ID' => $checkin_for_dtt_id)
),
'DTT_name');
$datetime_checkins_for_csv_col[] = $checkin_for_dtt_name ?
$checkin_for_dtt_name . ' - ID ' . $checkin_for_dtt_id :
$checkin_for_dtt_id;
$checkin_dtt_id_array[] = $checkin_for_dtt_id;
}
foreach (
\EEM_Datetime::instance()->get_all_wpdb_results(array(
array('Ticket.TKT_ID' => $reg_db_row['Ticket.TKT_ID']),
'order_by' => array('DTT_EVT_start' => 'ASC'),
'default_where_conditions' => 'none',
)) as $datetime
) {
$checked_in = '';
if (in_array($datetime['Datetime.DTT_ID'], $checkin_dtt_id_array ) ) {
$checked_in = 'x';
}
$csv_row[ (string) \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']) ] = $checked_in;
}
$csv_row[ (string)__( 'Checked in for Datetime', 'event_espresso' ) ] = implode( ' + ', $datetime_checkins_for_csv_col );
$csv_row[ (string)__( 'Checkin timestamps', 'event_espresso' ) ] = implode( ' + ', $checkins_for_csv_col );
return $csv_row;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment