Commit 9ab55a3d authored by ErikHommel's avatar ErikHommel
Browse files

version without bioresource_id

parent fdd1a0b3
......@@ -23,7 +23,6 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
['class' => 'crm-select2']);
$form->add('text', 'first_name', E::ts('First Name contains'), [], FALSE);
$form->add('text', 'last_name', E::ts('Last Name contains'), [], FALSE);
$form->add('text', 'bioresource_id', E::ts('Bioresource ID is'), [], FALSE);
// Optionally define default search values
$form->setDefaults([
'project_id' => NULL,
......@@ -33,7 +32,7 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$form->assign('elements', ['project_id', 'first_name', 'last_name', 'gender_id', 'bioresource_id']);
$form->assign('elements', ['project_id', 'first_name', 'last_name', 'gender_id']);
}
/**
......@@ -107,7 +106,6 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
// return by reference
$columns = [
E::ts('Name') => 'sort_name',
E::ts('BioResource ID') => 'nva_bioresource_id',
E::ts('Study/Part ID') => 'nvpd_study_participant_id',
E::ts('Gender') => 'gender',
E::ts('Age') => 'birth_date',
......@@ -143,15 +141,13 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
* @return string, sql fragment with SELECT arguments
*/
function select() {
$bioResourceIDColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerAliasCustomField('nva_bioresource_id', 'column_name');
$eligibleColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_eligible_status_id', 'column_name');
$studyParticipantIDColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_study_participant_id', 'column_name');
$dateInvitedColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_date_invited', 'column_name');
$distanceColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_distance_volunteer_to_study_centre', 'column_name');
return "
DISTINCT(contact_a.id) AS contact_id, contact_a.sort_name, nva." . $bioResourceIDColumn . ",
contact_a.birth_date, genderov.label AS gender, ethnicov.label AS ethnicity, adr.city AS volunteer_address,
nvpd." . $eligibleColumn . ", nvpd.". $studyParticipantIDColumn . ", prostatus.label AS project_status,
DISTINCT(contact_a.id) AS contact_id, contact_a.sort_name, contact_a.birth_date, genderov.label AS gender,
ethnicov.label AS ethnicity, adr.city AS volunteer_address, nvpd." . $eligibleColumn . ", nvpd.". $studyParticipantIDColumn . ", prostatus.label AS project_status,
stustatus.label AS study_status, nvpd." . $dateInvitedColumn . ", nvpd." . $distanceColumn;
}
......@@ -163,7 +159,6 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
function from() {
$nvgoTable = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerGeneralObservationsCustomGroup('table_name');
$nvpdTable = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationDataCustomGroup('table_name');
$nvaTable = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerAliasCustomGroup('table_name');
$genderOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getGenderOptionGroupId();
$ethnicityOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getEthnicityOptionGroupId();
$projectStatusOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getProjectParticipationStatusOptionGroupId();
......@@ -175,7 +170,6 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
FROM civicrm_contact AS contact_a
JOIN civicrm_case_contact AS ccc ON contact_a.id = ccc.contact_id
JOIN civicrm_case AS cas ON ccc.case_id = cas.id AND cas.is_deleted = 0
LEFT JOIN " . $nvaTable . " AS nva ON contact_a.id = nva.entity_id
LEFT JOIN " . $nvgoTable . " AS nvgo ON ccc.contact_id = nvgo.entity_id
LEFT JOIN civicrm_address AS adr ON contact_a.id = adr.contact_id AND adr.is_primary = 1
LEFT JOIN " . $nvpdTable . " AS nvpd ON cas.id = nvpd.entity_id
......@@ -216,7 +210,7 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
* @param $params
*/
private function addEqualsClauses(&$index, &$clauses, &$params) {
$equalFields = ['project_id', 'bioresource_id', 'gender_id'];
$equalFields = ['project_id', 'gender_id'];
foreach ($equalFields as $equalField) {
if (isset($this->_formValues[$equalField]) && !empty($this->_formValues[$equalField])) {
$index++;
......@@ -226,11 +220,6 @@ class CRM_Nbrprojectvolunteerlist_Form_Search_VolunteerList extends CRM_Contact_
$clauses[] = "nvpd." . $projectIdColumn . " = %" . $index;
$params[$index] = [$this->_formValues['project_id'], "Integer"];
break;
case 'bioresource_id':
$bioResourceIDColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerAliasCustomField('nva_bioresource_id', 'column_name');
$clauses[] = "nva" . $bioResourceIDColumn . " = %" . $index;
$params[$index] = [$this->_formValues['bioresource_id'], "String"];
break;
case 'gender_id':
if ($this->_formValues['gender_id'] != 0) {
$clauses[] = "contact_a.gender_id = %" . $index;
......
......@@ -21,24 +21,20 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ChangeProjectStatus extends CRM_Cont
*/
private function getSelectedData() {
$this->_selected = [];
$bioResourceColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerAliasCustomField('nva_bioresource_id', 'column_name');
$studyParticipantColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_study_participant_id', 'column_name');
$eligiblesColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_eligible_status_id', 'column_name');
$projectColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_project_id', 'column_name');
$statusColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_study_participation_status', 'column_name');
$participantTable = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationDataCustomGroup('table_name');
$aliasTable = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerAliasCustomGroup('table_name');
$ovpsOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getProjectParticipationStatusOptionGroupId();
$query = "
SELECT vol.id AS contact_id, vol.display_name, cvnva." . $bioResourceColumn . " AS bioresource_id,
cvnpd." . $studyParticipantColumn . " AS study_participant_id, cvnpd." . $eligiblesColumn . " AS eligible_status_id,
ovps.label AS project_status
SELECT vol.id AS contact_id, vol.display_name, cvnpd." . $studyParticipantColumn . " AS study_participant_id,
cvnpd." . $eligiblesColumn . " AS eligible_status_id, ovps.label AS project_status
FROM " . $participantTable . " AS cvnpd
JOIN civicrm_case_contact AS ccc ON cvnpd.entity_id = ccc.case_id
JOIN civicrm_case AS cas ON ccc.case_id = cas.id
JOIN civicrm_contact AS vol ON ccc.contact_id = vol.id
LEFT JOIN civicrm_option_value AS ovps ON cvnpd." . $statusColumn. " = ovps.value AND ovps.option_group_id = " . $ovpsOptionGroupId . "
LEFT JOIN " . $aliasTable. " AS cvnva ON vol.id = cvnva.entity_id
WHERE cvnpd." . $projectColumn. " = %1 AND cas.is_deleted = %2 AND vol.id IN (";
$queryParams = [
1 => [(int)$this->_projectId, "Integer"],
......@@ -56,7 +52,6 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ChangeProjectStatus extends CRM_Cont
while ($dao->fetch()) {
$volunteer = [
'display_name' => $dao->display_name,
'bioresource_id' => $dao->bioresource_id,
'study_participant_id' => $dao->study_participant_id,
'eligible_status' => implode(', ', CRM_Nihrbackbone_NbrVolunteerCase::getEligibleDescriptions($dao->eligible_status_id)),
'project_status' => $dao->project_status,
......
......@@ -21,24 +21,20 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ChangeStudyStatus extends CRM_Contac
*/
private function getSelectedData() {
$this->_selected = [];
$bioResourceColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerAliasCustomField('nva_bioresource_id', 'column_name');
$studyParticipantColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_study_participant_id', 'column_name');
$eligiblesColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_eligible_status_id', 'column_name');
$projectColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_project_id', 'column_name');
$statusColumn = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationCustomField('nvpd_study_participation_status', 'column_name');
$participantTable = CRM_Nihrbackbone_BackboneConfig::singleton()->getParticipationDataCustomGroup('table_name');
$aliasTable = CRM_Nihrbackbone_BackboneConfig::singleton()->getVolunteerAliasCustomGroup('table_name');
$ovssOptionGroupId = CRM_Nihrbackbone_BackboneConfig::singleton()->getStudyParticipationStatusOptionGroupId();
$query = "
SELECT vol.id AS contact_id, vol.display_name, cvnva." . $bioResourceColumn . " AS bioresource_id,
cvnpd." . $studyParticipantColumn . " AS study_participant_id, cvnpd." . $eligiblesColumn . " AS eligible_status_id,
ovss.label AS study_status
SELECT vol.id AS contact_id, vol.display_name, cvnpd." . $studyParticipantColumn . " AS study_participant_id,
cvnpd." . $eligiblesColumn . " AS eligible_status_id, ovss.label AS study_status
FROM " . $participantTable . " AS cvnpd
JOIN civicrm_case_contact AS ccc ON cvnpd.entity_id = ccc.case_id
JOIN civicrm_case AS cas ON ccc.case_id = cas.id
JOIN civicrm_contact AS vol ON ccc.contact_id = vol.id
LEFT JOIN civicrm_option_value AS ovss ON cvnpd." . $statusColumn . " = ovss.value AND ovss.option_group_id = " . $ovssOptionGroupId . "
LEFT JOIN " . $aliasTable. " AS cvnva ON vol.id = cvnva.entity_id
WHERE cvnpd." . $projectColumn. " = %1 AND cas.is_deleted = %2 AND vol.id IN (";
$queryParams = [
1 => [(int)$this->_projectId, "Integer"],
......@@ -56,7 +52,6 @@ class CRM_Nbrprojectvolunteerlist_Form_Task_ChangeStudyStatus extends CRM_Contac
while ($dao->fetch()) {
$volunteer = [
'display_name' => $dao->display_name,
'bioresource_id' => $dao->bioresource_id,
'study_participant_id' => $dao->study_participant_id,
'eligible_status' => implode(', ', CRM_Nihrbackbone_NbrVolunteerCase::getEligibleDescriptions($dao->eligible_status_id)),
'study_status' => $dao->study_status,
......
# nbrprojectvolunteerlist
![Screenshot](/images/screenshot.png)
(*FIXME: In one or two paragraphs, describe what the extension does and why one would download it. *)
The extension is licensed under [AGPL-3.0](LICENSE.txt).
## Requirements
* PHP v5.4+
* CiviCRM (*FIXME: Version number*)
## Installation (Web UI)
This extension has not yet been published for installation via the web UI.
## Installation (CLI, Zip)
Sysadmins and developers may download the `.zip` file for this extension and
install it with the command-line tool [cv](https://github.com/civicrm/cv).
```bash
cd <extension-dir>
cv dl nbrprojectvolunteerlist@https://github.com/FIXME/nbrprojectvolunteerlist/archive/master.zip
```
## Installation (CLI, Git)
Sysadmins and developers may clone the [Git](https://en.wikipedia.org/wiki/Git) repo for this extension and
install it with the command-line tool [cv](https://github.com/civicrm/cv).
```bash
git clone https://github.com/FIXME/nbrprojectvolunteerlist.git
cv en nbrprojectvolunteerlist
```
## Usage
(* FIXME: Where would a new user navigate to get started? What changes would they see? *)
## Known Issues
(* FIXME *)
NIHR BioResource extension for Project Volunteer List and Tasks
......@@ -9,20 +9,19 @@
<email>erik.hommel@civicoop.org</email>
</maintainer>
<urls>
<url desc="Main Extension Page">http://FIXME</url>
<url desc="Documentation">http://FIXME</url>
<url desc="Support">http://FIXME</url>
<url desc="Main Extension Page">https://lab.civicrm.org/partners/civicoop/nihr-bioresearch/nbrprojectvolunteerlist</url>
<url desc="Documentation">https://lab.civicrm.org/partners/civicoop/nihr-bioresearch/nbrprojectvolunteerlist</url>
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2019-10-30</releaseDate>
<version>1.0</version>
<releaseDate>2019-11-26</releaseDate>
<version>1.1</version>
<develStage>alpha</develStage>
<compatibility>
<ver>4.7</ver>
</compatibility>
<requires>
<ext>nihrbackbone</ext>
<ext>nbrcivisettings</ext>
</requires>
<comments>This is a new, undeveloped module</comments>
<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