<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
);
public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report');
- protected $_add2groupSupported = FALSE; function __construct() {
+ protected $_add2groupSupported = FALSE;
+
+ function __construct() {
$yearsInPast = 10;
$yearsInFuture = 1;
$date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture);
array('title' => ts('Donor Name'),
'required' => TRUE,
),
- 'first_name' => array('title' => ts('First Name'),
+ 'first_name' => array(
+ 'title' => ts('First Name'),
+ ),
+ 'last_name' => array(
+ 'title' => ts('Last Name'),
),
- 'last_name' => array('title' => ts('Last Name'),
+ 'contact_type' =>
+ array(
+ 'title' => ts('Contact Type'),
+ ),
+ 'contact_sub_type' =>
+ array(
+ 'title' => ts('Contact SubType'),
),
),
'filters' =>
),
),
),
+ )
+ + $this->addAddressFields()
+ + array(
'civicrm_contribution' =>
array(
'dao' => 'CRM_Contribute_DAO_Contribution',
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $fieldName => $field) {
- if (CRM_Utils_Array::value('required', $field) ||
- CRM_Utils_Array::value($fieldName, $this->_params['fields'])
- ) {
+ if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
if ($fieldName == 'total_amount') {
$select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}";
$this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
$this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
}
- if (CRM_Utils_Array::value('no_display', $field)) {
+ if (!empty($field['no_display'])) {
$this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = TRUE;
}
}
function from() {
- $this->_from = "
+ $this->_from = "
FROM civicrm_contribution {$this->_aliases['civicrm_contribution']}
- INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
- {$this->_aclFrom}
- LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id
- AND {$this->_aliases['civicrm_email']}.is_primary = 1
- LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
- {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
+ INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
+ ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
+ {$this->_aclFrom}";
+
+ if ($this->isTableSelected('civicrm_email')) {
+ $this->_from .= "
+ LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
+ ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id
+ AND {$this->_aliases['civicrm_email']}.is_primary = 1";
+ }
+ if ($this->isTableSelected('civicrm_phone')) {
+ $this->_from .= "
+ LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
+ ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
+ {$this->_aliases['civicrm_phone']}.is_primary = 1";
+ }
+ $this->addAddressFromClause();
}
function where() {
$this->groupBy();
$rows = $contactIds = array();
- if (!CRM_Utils_Array::value('charts', $this->_params)) {
+ if (empty($this->_params['charts'])) {
$this->limit();
$getContacts = "SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid {$this->_from} {$this->_where} GROUP BY {$this->_aliases['civicrm_contact']}.id {$this->_limit}";
$this->setPager();
}
- if (!empty($contactIds) || CRM_Utils_Array::value('charts', $this->_params)) {
- if (CRM_Utils_Array::value('charts', $this->_params)) {
+ if (!empty($contactIds) || !empty($this->_params['charts'])) {
+ if (!empty($this->_params['charts'])) {
$sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}";
}
else {
}
function alterDisplay(&$rows) {
+ // custom code to alter rows
+ $entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
//Convert Display name into link
);
$rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contribution Details for this Contact.");
+ $entryFound = TRUE;
}
// convert campaign_id to campaign title
$entryFound = TRUE;
}
}
+
+ $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s)') ? TRUE : $entryFound;
+
+ // skip looking further in rows, if first row itself doesn't
+ // have the column we need
+ if (!$entryFound) {
+ break;
+ }
}
}