Skip to content

Instantly share code, notes, and snippets.

@bhahumanists
Created June 18, 2020 12:20
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 bhahumanists/98a6a154a394f008a86fec55d855f3ae to your computer and use it in GitHub Desktop.
Save bhahumanists/98a6a154a394f008a86fec55d855f3ae to your computer and use it in GitHub Desktop.
Example multivalue report
<?php
// $Id$
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
* $Id$
*
*/
class CRM_Report_Form_AllGiftAidData extends CRM_Report_Form {
protected $_summary = NULL;
protected $_emailField = FALSE;
protected $_phoneField = FALSE;
protected $_noFields = TRUE;
function preProcess() {
parent::preProcess();
}
function select() {
$select = [];
$this->_columnHeaders = [];
$this->_select = "select entity_id, display_name, eligible_for_gift_aid, address, post_code, start_date, end_date, reason_ended, cvgad.source, notes, scanned_declaration, scanned_declaration_exists__658, cc.display_name";
$this->_columnHeaders = [
'entity_id' => ['type' => 0, 'title' => 'ContactID'],
'display_name' => ['type' => 0, 'title' => 'Name'],
'eligible_for_gift_aid' => ['type' => 0, 'title' => 'Eligible'],
'address' => ['type' => 0, 'title' => 'Address'],
'post_code' => ['type' => 0, 'title' => 'Postcode'],
'start_date' => ['type' => 0, 'title' => 'Start Date'],
'end_date' => ['type' => 0, 'title' => 'End Date'],
'reason_ended' => ['type' => 0, 'title' => 'Reason Ended'],
'cvgad.source' => ['type' => 0, 'title' => 'Source'],
'notes' => ['type' => 0, 'title' => 'Notes'],
'scanned_declaration' => ['type' => 0, 'title' => 'Scanned Declaration'],
'scanned_declaration_exists__658' => ['type' => 0, 'title' => 'Scanned Declaration Exists'],
];
}
static function formRule($fields, $files, $self) {
$errors = $grouping = [];
return $errors;
}
function from() {
$this->_from = "
FROM civicrm_value_gift_aid_declaration cvgad left join civicrm_contact cc on cc.id = cvgad.entity_id";
}
function where() {
$this->_where = "";
}
function groupBy() {
$this->_groupBy = "";
}
function orderBy() {
$this->_orderBy = "order by entity_id";
}
function postProcess() {
$this->beginPostProcess();
// get the acl clauses built before we assemble the query
$this->buildACLClause($this->_aliases['civicrm_contact']);
$sql = $this->buildQuery(TRUE);
$rows = $graphRows = [];
$this->buildRows($sql, $rows);
$this->formatDisplay($rows);
$this->doTemplateAssignment($rows);
$this->endPostProcess($rows);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment