Commit 7d91a445 authored by ErikHommel's avatar ErikHommel
Browse files

fix issue 6563

parent 97f938c4
## Version 1.32
* issue 6563: export data from MSP
* issue 6563: export data from MSP and fix address on export for external researcher
## Version 1.31
* issue 7505: generate study participation ID in the invite task before sending out the actual email.
......
......@@ -554,37 +554,17 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
break;
case 'volunteer_tags':
$row['volunteer_tags'] = $this->getContactTags($row['contact_id']);
$vol = new CRM_Nbrprojectvolunteerlist_NbrVolunteer();
$tags = $vol->getContactTags($row['contact_id']);
if (strlen($tags) > 80) {
$tags = substr($tags,0,77) . '...';
}
$row['volunteer_tags'] = $tags;
break;
}
}
}
/**
* Method to get tag names for volunteer (with max 80 chars)
*
* @param $contactId
* @return string
* @throws API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
private function getContactTags($contactId) {
$result = [];
$entityTags = \Civi\Api4\EntityTag::get()
->addSelect('tag.name')
->addWhere('entity_table', '=', 'civicrm_contact')
->addWhere('entity_id', '=', $contactId)
->execute();
foreach ($entityTags as $entityTag) {
$result[] = $entityTag['tag.name'];
}
$text = implode(",", $result);
if (strlen($text) > 80) {
$text = substr($text,0,77) . '...';
}
return $text;
}
/**
* Get the defaults for the entity for any fields described in metadata.
*
......
......@@ -36,7 +36,8 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ExportExternal extends CRM_Contact_F
$genderOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getGenderOptionGroupId();
$query = "SELECT a." . $studyPartIdColumn . " AS study_participant_id , a." . $recallColumn
. " AS recall_group, a." . $statusColumn . " AS study_status_id, a. " . $inviteColumn . " AS date_invited,
h.label AS study_status, d.first_name, d.last_name, i.label AS gender, e.email, f.street_address,
h.label AS study_status, d.first_name, d.last_name, i.label AS gender, e.email,
CONCAT_WS(', ', f.street_address, f.supplemental_address_1, f.supplemental_address_2, supplemental_address_3) AS address,
TIMESTAMPDIFF(YEAR, d.birth_date , CURDATE()) AS age, f.city, f.postal_code, g.name AS county,
b.contact_id, d.birth_date, b.case_id
FROM " . $participantTable . " AS a
......@@ -68,7 +69,7 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ExportExternal extends CRM_Contact_F
'age' => $dao->age,
'gender' => $dao->gender,
'email' => $dao->email,
'street_address' => $dao->street_address,
'street_address' => $dao->address,
'city' => $dao->city,
'county' => $dao->county,
'postal_code' => $dao->postal_code,
......
......@@ -34,10 +34,9 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ExportSelect extends CRM_Contact_For
$statusOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getStudyParticipationStatusOptionGroupId();
$genderOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getGenderOptionGroupId();
$query = "SELECT a." . $studyPartIdColumn . " AS study_participant_id , a." . $recallColumn
. " AS recall_group, a." . $statusColumn . " AS study_status_id, a." . $inviteColumn
. " AS date_invited, a. " . $distanceColumn . " AS distance, h.label AS study_status,
CONCAT_WS(' ', d.first_name, d.last_name) AS name, i.label AS gender, e.email,
CONCAT_WS(', ', f.street_address, f.supplemental_address_1, f.supplemental_address_2,
. " AS recall, a." . $inviteColumn . " AS date_invited, a. " . $distanceColumn
. " AS distance, h.label AS status, CONCAT_WS(' ', d.first_name, d.last_name) AS name,
i.label AS gender, e.email, CONCAT_WS(', ', f.street_address, f.supplemental_address_1, f.supplemental_address_2,
f.supplemental_address_3, f.city, f.postal_code) AS address, f.city, k.phone,
m.label AS ethnicity, TIMESTAMPDIFF(YEAR, d.birth_date , CURDATE()) AS age, g.name AS county,
j." . $bioResourceIdColumn . " AS bioresource_id, j." . $participantIdColumn . " AS participant_id,
......@@ -148,8 +147,13 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ExportSelect extends CRM_Contact_For
$row[] = "";
}
break;
case "tags":
$vol = new CRM_Nbrprojectvolunteerlist_NbrVolunteer();
$row[] = $vol->getContactTags($volunteer['contact_id']);
break;
default:
if ($volunteer[$exportField]) {
if (isset($volunteer[$exportField]) && !empty($volunteer[$exportField])) {
$row[] = $volunteer[$exportField];
}
else {
......
......@@ -113,5 +113,27 @@ class CRM_Nbrprojectvolunteerlist_NbrVolunteer {
return FALSE;
}
/**
* Method to get tag names for volunteer (with max 80 chars)
*
* @param $contactId
* @return string
* @throws API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function getContactTags($contactId) {
$result = [];
$entityTags = \Civi\Api4\EntityTag::get()
->addSelect('tag.name')
->addWhere('entity_table', '=', 'civicrm_contact')
->addWhere('entity_id', '=', $contactId)
->execute();
foreach ($entityTags as $entityTag) {
$result[] = $entityTag['tag.name'];
}
return implode(",", $result);
}
}
......@@ -14,16 +14,16 @@
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-03-03</releaseDate>
<releaseDate>2021-03-09</releaseDate>
<version>1.32</version>
<develStage>beta</develStage>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
</compatibility>
<requires>
<ext>nihrbackbone</ext>
</requires>
<comments>Extension is being tested</comments>
<comments>Extension is live</comments>
<civix>
<namespace>CRM/Nbrprojectvolunteerlist</namespace>
</civix>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment