public static function getCustomRecordLabelsSecondaryFieldAllRecords($records = array(), $removeHtml = false, $arm = null, $boldSecondaryPkValue = false, $cssClass = 'crl') { global $is_child, $secondary_pk, $custom_record_label, $Proj; // Determine which arm to pull these values for if ($arm == 'all' && $Proj->longitudinal && $Proj->multiple_arms) { // If project has more than one arm, then get first event_id of each arm $event_ids = array(); foreach (array_keys($Proj->events) as $this_arm) { $event_ids[] = $Proj->getFirstEventIdArm($this_arm); } } else { // Get arm if ($arm === null) { $arm = getArm(); } // Get event_id of first event of the given arm $event_ids = array($Proj->getFirstEventIdArm(is_numeric($arm) ? $arm : getArm())); } // Place all records/labels in array $extra_record_labels = array(); // If $records is a string, then convert to array $singleRecordName = null; if (!is_array($records)) { $singleRecordName = $records; $records = array($records); } // Set flag to limit records $limitRecords = !empty($records); // Customize the Record ID pulldown menus using the SECONDARY_PK appended on end, if set. if ($secondary_pk != '' && !$is_child) { // Get validation type of secondary unique field $val_type = $Proj->metadata[$secondary_pk]['element_validation_type']; $convert_date_format = substr($val_type, 0, 5) == 'date_' && (substr($val_type, -4) == '_mdy' || substr($val_type, -4) == '_mdy'); // Set secondary PK field label $secondary_pk_label = $Proj->metadata[$secondary_pk]['element_label']; // PIPING: Obtain saved data for all piping receivers used in secondary PK label if (strpos($secondary_pk_label, '[') !== false && strpos($secondary_pk_label, ']') !== false) { // Get fields in the label $secondary_pk_label_fields = array_keys(getBracketedFields($secondary_pk_label, true, true, true)); // If has at least one field piped in the label, then get all the data for these fields and insert one at a time below if (!empty($secondary_pk_label_fields)) { $piping_record_data = Records::getData('array', $records, $secondary_pk_label_fields, $event_ids); } } // Get back-end data for the secondary PK field $sql = "select record, event_id, value from redcap_data \n\t\t\t\t\twhere project_id = " . PROJECT_ID . " and field_name = '{$secondary_pk}' \n\t\t\t\t\tand event_id in (" . prep_implode($event_ids) . ")"; if ($limitRecords) { $sql .= " and record in (" . prep_implode($records) . ")"; } $q = db_query($sql); while ($row = db_fetch_assoc($q)) { // Set the label for this loop (label may be different if using piping in it) if (isset($piping_record_data)) { // Piping: pipe record data into label for each record $this_secondary_pk_label = Piping::replaceVariablesInLabel($secondary_pk_label, $row['record'], $event_ids, $piping_record_data); } else { // Static label for all records $this_secondary_pk_label = $secondary_pk_label; } // If the secondary unique field is a date/time field in MDY or DMY format, then convert to that format if ($convert_date_format) { $row['value'] = DateTimeRC::datetimeConvert($row['value'], 'ymd', substr($val_type, -3)); } // Set text value $this_string = "(" . remBr($this_secondary_pk_label . " " . ($boldSecondaryPkValue ? "<b>" : "") . filter_tags(label_decode($row['value']))) . ($boldSecondaryPkValue ? "</b>" : "") . ")"; // Add HTML around string (unless specified otherwise) $extra_record_labels[$Proj->eventInfo[$row['event_id']]['arm_num']][$row['record']] = $removeHtml ? $this_string : RCView::span(array('class' => $cssClass), $this_string); } db_free_result($q); } // [Retrieval of ALL records] If Custom Record Label is specified (such as "[last_name], [first_name]"), then parse and display // ONLY get data from FIRST EVENT if (!empty($custom_record_label)) { // Loop through each event (will only be one UNLESS we are attempting to get label for multiple arms) $customRecordLabelsArm = array(); foreach ($event_ids as $this_event_id) { $customRecordLabels = getCustomRecordLabels($custom_record_label, $this_event_id, $singleRecordName ? $records[0] : null); if (!is_array($customRecordLabels)) { $customRecordLabels = array($records[0] => $customRecordLabels); } $customRecordLabelsArm[$Proj->eventInfo[$this_event_id]['arm_num']] = $customRecordLabels; } foreach ($customRecordLabelsArm as $this_arm => &$customRecordLabels) { foreach ($customRecordLabels as $this_record => $this_custom_record_label) { // If limiting by records, ignore if not in $records array if ($limitRecords && !in_array($this_record, $records)) { continue; } // Set text value $this_string = remBr(filter_tags(label_decode($this_custom_record_label))); // Add initial space OR add placeholder if (isset($extra_record_labels[$this_arm][$this_record])) { $extra_record_labels[$this_arm][$this_record] .= ' '; } else { $extra_record_labels[$this_arm][$this_record] = ''; } // Add HTML around string (unless specified otherwise) $extra_record_labels[$this_arm][$this_record] .= $removeHtml ? $this_string : RCView::span(array('class' => $cssClass), $this_string); } } } // If we're not collecting multiple arms here, then remove arm key if ($arm != 'all') { $extra_record_labels = array_shift($extra_record_labels); } // Return string (single record only) if ($singleRecordName != null) { return isset($extra_record_labels[$singleRecordName]) ? $extra_record_labels[$singleRecordName] : ''; } else { // Return array return $extra_record_labels; } }
require_once APP_PATH_DOCROOT . 'ProjectGeneral/form_renderer_functions.php'; if (PAGE == "DataEntry/grid.php") { $fetched = $_GET['id']; } $record_display = RCView::b(RCView::escape($_GET['id'])); // Get Custom Record Label and Secondary Unique Field values (if applicable) $this_custom_record_label_secondary_pk = Records::getCustomRecordLabelsSecondaryFieldAllRecords(addDDEending($fetched), false, getArm(), true); if ($this_custom_record_label_secondary_pk != '') { $record_display .= " $this_custom_record_label_secondary_pk"; } // DISPLAY RECORD NAME: Set full string for record name with prepended label (e.g., Study ID 202) if ($longitudinal) { // Longitudinal project: Display record name as link and "select other record" link $record_label = RCView::div(array('style'=>'padding:0 0 4px;color:#800000;font-size:12px;'), RCView::div(array('style'=>'float:left;'), RCView::a(array('style'=>'color:#800000;','href'=>APP_PATH_WEBROOT."DataEntry/grid.php?pid=$project_id&id=$fetched&arm=".getArm()), RCView::img(array('src'=>'application_view_tile.png','class'=>'imgfix')) . strip_tags(label_decode($table_pk_label)) . " " . $record_display ) ) . RCView::div(array('style'=>'float:right;line-height:18px;'), RCView::a(array('id'=>'menuLnkChooseOtherRec','class'=>'opacity50','style'=>'color:#000066;vertical-align:middle;text-decoration:underline;font-size:10px;','href'=>APP_PATH_WEBROOT."DataEntry/grid.php?pid=$project_id"), $lang['bottom_63'] ) ) . RCView::div(array('class'=>'clear'), '') ); } else { // Classic project: Display record name and "select other record" link $record_label = RCView::div(array('style'=>'padding:0 0 4px;color:#800000;font-size:12px;'), RCView::div(array('style'=>'float:left;font-family:arial;'),
*/ $base_path = dirname(dirname(dirname(__FILE__))); require_once $base_path . '/plugins/includes/functions.php'; // Auto-number logic (pre-submission of new record) if ($auto_inc_set) { // If the auto-number record selected has already been created by another user, fetch the next one to prevent overlapping data if (isset($_GET['id']) && isset($_GET['auto'])) { $q = db_query("select 1 from redcap_data where project_id = {$project_id} and record = '" . prep($_GET['id']) . "' limit 1"); if (db_num_rows($q) > 0) { // Record already exists, so redirect to new page with this new record value redirect(PAGE_FULL . "?pid={$project_id}&page={$_GET['page']}&id=" . getAutoId()); } } } //Get arm number from URL var 'arm' $arm = getArm(); // Reload page if id is a blank value if (isset($_GET['id']) && trim($_GET['id']) == "") { redirect(PAGE_FULL . "?pid=" . PROJECT_ID . "&page=" . $_GET['page'] . "&arm=" . $arm); exit; } // Clean id if (isset($_GET['id'])) { $_GET['id'] = strip_tags(label_decode($_GET['id'])); } //include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; require_once $base_path . '/plugins/Overrides/ProjectGeneral/header_advanced_grid.php'; // Hook: redcap_add_edit_records_page Hooks::call('redcap_add_edit_records_page', array(PROJECT_ID, null, null)); // Header if (isset($_GET['id'])) {