Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Won't Fix
-
Affects Version/s: 4.1.5
-
Fix Version/s: Unscheduled
-
Component/s: CiviReport
-
Labels:None
-
Documentation Required?:None
-
Funding Source:Needs Funding
Description
OK logging this here as I'm not including it in any main reports - this is the patch I'm using to enable to add contacts other than the main contact to a group from a report
You then need to add this to the report
protected $_add2GroupcontactTables = array(
'civicrm_contact' => 'Subscriber',
'employer_civicrm_contact' => 'Employer',
'honor_civicrm_contact' => 'Giftee'
);
Index: CRM/Report/Form.php
===================================================================
— CRM/Report/Form.php (revision 41947)
+++ CRM/Report/Form.php (working copy)
@@ -891,6 +891,11 @@
array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup()
);
$this->assign('group', TRUE);
+ if(is_array($this->_add2GroupcontactTables) && count($this->_contactTables > 1))
}
$label = ts('Add these Contacts to Group');
@@ -3109,11 +3114,15 @@
}
function add2group($groupID) {
- if (is_numeric($groupID) && isset($this->_aliases['civicrm_contact'])) {
- $select = "SELECT DISTINCT {$this->_aliases['civicrm_contact']}.id AS addtogroup_contact_id, ";
- $select = str_ireplace('SELECT SQL_CALC_FOUND_ROWS ', $select, $this->_select);
+ if (is_numeric($groupID) && isset($this->_aliases['honor_civicrm_contact'])) {
+ require_once 'CRM/Contact/BAO/GroupContact.php';
- $sql = "{$select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy}";
+ $contact = $this->_submitValues['btn_group_contact'];
+ $select = "SELECT DISTINCT {$this->_aliases[$contact]}.id AS addtogroup_contact_id";
+ // $select = str_ireplace('SELECT SQL_CALC_FOUND_ROWS ', $select, $this->_select);
+
+ $sql = "{$select} {$this->_from} {$this->_where} AND {$this->_aliases[$contact]}.id IS NOT NULL {$this->_groupBy} {$this->_having} {$this->_orderBy}";
+
$dao = CRM_Core_DAO::executeQuery($sql);
$contact_ids = array();
Index: templates/CRM/Report/Form/Actions.tpl
===================================================================
— templates/CRM/Report/Form/Actions.tpl (revision 41947)
+++ templates/CRM/Report/Form/Actions.tpl (working copy)
@@ -48,13 +48,19 @@
</table>
</td>
<td>
- <table class="form-layout-compressed" align="right">
+ <table class="form-layout-compressed" align="right"> {if $chartSupported}<tr>
{/if}
<td>{$form.charts.html|crmReplace:class:big}</td>
<td align="right">{$form.$chart.html}</td>
</tr>
+ {if $form.btn_group_contact}
+ <tr>
+ <td>{$form.btn_group_contact.html|crmReplace:class:big}</td>
+ <td align="right">{$form.$btn_group_contact.html}</td>
+ </tr>
+ {/if} {if $form.groups}<tr>
<td>{$form.groups.html|crmReplace:class:big}</td>