*/
$item_count = 0;
$today = date('Y-m-d');
$rows = '';
/**
 * query target_email_actions for any actions that haven't yet been digested.
 * digest and send them
 */
$actions_result = db_query("SELECT DISTINCT * FROM target_email_actions WHERE (digest_date IS NULL OR digest_date = '') AND project_id = '$project_id' ORDER BY redcap_data_access_group ASC, abs(record) ASC");
if ($actions_result) {
	while ($actions_row = db_fetch_assoc($actions_result)) {
		$item_count++;
		foreach ($actions_row AS $key => $value) {
			$$key = $value;
		}
		$event_keys = Event::getUniqueKeys($project_id);
		$event_id = array_search($redcap_event_name, $event_keys);
		$url = APP_PATH_WEBROOT_FULL . "redcap_v" . $redcap_version . "/DataEntry/index.php?pid=$project_id&id=$record&event_id=$event_id&page=$form_name";
		$rows .= RCView::tr(array('style' => 'border:1px solid #d0d0d0;'),
			RCView::td(array('class' => 'data_1', 'style' => "font-family:Verdana;font-size:8pt;background-color:" . row_style($item_count) . ";border:1px solid #CCCCCC;text-align:left;padding:5px 8px;"),
				"<a href='{$url}'>$record</a>"
			) .
			RCView::td(array('class' => 'data_1', 'style' => "font-family:Verdana;font-size:8pt;background-color:" . row_style($item_count) . ";border:1px solid #CCCCCC;text-align:left;padding:5px 8px;"),
				$redcap_data_access_group
			)
		);
		if (!$debug) {
			if (!db_query("UPDATE target_email_actions SET digest_date = '$today' WHERE action_id = '$action_id'")) {
				error_log("ERROR: failed to update target_email_actions.digest_date");
			}
		}