-
-
Save ahed-compucorp/672363f80c076a80c2804b78f61baaa9 to your computer and use it in GitHub Desktop.
Example of using civicrm_alterReportVar hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_civicrm_alterReportVar(). | |
*/ | |
function myextension_civicrm_alterReportVar($varType, &$var, &$reportForm) { | |
if ($varType === 'columns') { | |
$var['civicrm_value_extension_tng55'] = [ | |
'fields' => [ | |
'extension_tng55_title' => [ | |
'title' => ts('Extension Title'), | |
'dbAlias' => "civicrm_value_extension_tng55.title", | |
], | |
], | |
'filters' => [ | |
'extension_tng55_title' => [ | |
'title' => ts('Extension Title'), | |
'dbAlias' => "civicrm_value_extension_tng55.title", | |
'type' => CRM_Utils_Type::T_INT, | |
'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
'options' => [ | |
1 => 'title 1' | |
], | |
], | |
], | |
]; | |
} | |
if ($varType === 'sql') { | |
if (isset($reportForm->getVar('_params')['fields']['extension_tng55_title']) | |
|| isset($reportForm->getVar('_params')['extension_tng55_title_op'])) { | |
$from = $var->getVar('_from'); | |
$from .= " | |
LEFT JOIN civicrm_value_extension_tng55 | |
ON (civicrm_value_extension_tng55.entity_id = contribution_civireport.id) | |
"; | |
$var->setVar('_from', $from); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment