Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ahed-compucorp
Last active January 4, 2021 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahed-compucorp/672363f80c076a80c2804b78f61baaa9 to your computer and use it in GitHub Desktop.
Save ahed-compucorp/672363f80c076a80c2804b78f61baaa9 to your computer and use it in GitHub Desktop.
Example of using civicrm_alterReportVar hook
<?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