Fixed report to retrieve only contacts with donot trade = 0

This commit is contained in:
CiviWare Solutions 2018-08-30 16:33:22 +01:00
parent 1c455e639f
commit 8ac621f5ce

View File

@ -146,33 +146,12 @@ function constituentsonly_civicrm_apiWrappers(&$wrappers, $apiRequest) {
} }
/** /**
* Implements hook_civicrm_alterReportVar(). * Implements hook_civicrm_selectWhereClause().
* *
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterReportVar * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_selectWhereClause
*/ */
function constituentsonly_civicrm_alterReportVar($varType, &$var, &$object) { function constituentsonly_civicrm_selectWhereClause($entity, &$clauses) {
$instanceValue = $object->getVar('_instanceValues'); if ($entity == 'Contact') {
if (!empty($instanceValue) && $clauses['do_not_trade'] = ' = 0';
in_array(
$instanceValue['report_id'],
array(
'contact/summary',
'contact/detail',
'contact/currentEmployer',
)
)
) {
if ($varType == 'sql') {
$var->_columnHeaders['civicrm_contact_do_not_trade'] = array(
'type' => 1,
'title' => 'Constituent',
'no_display' => TRUE,
);
$var->_select .= ' , contact_civireport.do_not_trade as civicrm_contact_do_not_trade ';
$where = $var->getVar('_where');
$where .= ' AND contact_civireport.do_not_trade <> 1';
$var->setVar('_where', $where);
}
} }
} }