Commit 1c96c086 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

Update extendedreport

parent cf24b4fe
......@@ -31,6 +31,7 @@ class CRM_Extendedreport_Form_Report_ActivityEditable extends CRM_Extendedreport
$this->_columns['civicrm_activity']['fields']['id'] = array(
'title' => 'id',
'required' => TRUE,
'type' => CRM_Utils_Type::T_INT,
);
parent::__construct();
}
......
......@@ -4,37 +4,25 @@
* Class CRM_Extendedreport_Form_Report_ActivityExtended
*/
class CRM_Extendedreport_Form_Report_ActivityExtended extends CRM_Extendedreport_Form_Report_ExtendedReport {
//todo move def to getActivityColumns
/**
* @var array
*/
protected $_customGroupExtended = array(
'civicrm_activity' => array(
'extends' => array('Activity'),
'title' => 'Activity',
'filters' => TRUE,
),
);
/**
* @var bool
*/
protected $_addressField = FALSE;
protected $_customGroupExtends = ['Activity', 'Contact', 'Individual', 'Household', 'Organization'];
protected $_editableFields = FALSE;
/**
* Can this report be used on a contact tab.
*
* The report must support contact_id in the url for this to work.
*
* @var bool
*/
protected $_emailField = FALSE;
/**
* @var null
*/
protected $_summary = NULL;
protected $isSupportsContactTab = TRUE;
/**
* @var bool
*/
protected $_exposeContactID = FALSE;
/**
* @var bool
*/
protected $_customGroupGroupBy = FALSE;
/**
* @var string
*/
......@@ -42,8 +30,6 @@ class CRM_Extendedreport_Form_Report_ActivityExtended extends CRM_Extendedreport
/**
* Class constructor.
*
* @todo allow filtering on other contacts
*/
public function __construct() {
$this->_columns = $this->getColumns(
......@@ -109,7 +95,6 @@ class CRM_Extendedreport_Form_Report_ActivityExtended extends CRM_Extendedreport
AND civicrm_email_assignee.is_deleted = 0
";
}
$this->selectableCustomDataFrom();
}
/**
......
......@@ -39,6 +39,19 @@ class CRM_Extendedreport_Form_Report_Case_CasePivot extends CRM_Extendedreport_F
$this->_columns['civicrm_case']['fields']['case_civireport_status_id']['no_display'] = TRUE;
$this->_columns['civicrm_case']['filters']['case_civireport_is_deleted']['default'] = 0;
$this->_columns['civicrm_case']['metadata']['case_civireport_id'] = array_merge(
['is_fields' => FALSE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, 'is_order_bys' => FALSE, 'is_join_filters' => FALSE],
$this->_columns['civicrm_case']['fields']['case_civireport_id']
);
$this->_columns['civicrm_case']['metadata']['case_civireport_status_id'] = array_merge(
['is_fields' => FALSE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, 'is_order_bys' => FALSE, 'is_join_filters' => FALSE],
$this->_columns['civicrm_case']['fields']['case_civireport_status_id']
);
$this->_columns['civicrm_case']['metadata']['case_civireport_is_deleted'] = array_merge(
['is_fields' => FALSE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, 'is_order_bys' => FALSE, 'is_join_filters' => FALSE],
$this->_columns['civicrm_case']['filters']['case_civireport_is_deleted']
);
$this->_aggregateRowFields = array(
'case_civireport:id' => 'Case',
'case_civireport:status_id' => 'Case Status',
......
......@@ -34,7 +34,7 @@ class CRM_Extendedreport_Form_Report_Contact_AddressHistory extends CRM_Extended
'fields' => TRUE,
'order_by' => FALSE,
//'fields_defaults' => array('address_name', 'street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'country_id', 'postal_code', 'county_id'),
'fields_defaults' => array('display_address'),
'fields_defaults' => array('display_address'),
)
);
......@@ -84,6 +84,14 @@ class CRM_Extendedreport_Form_Report_Contact_AddressHistory extends CRM_Extended
'default' => 1,
),
);
foreach ($logMetaData as $index => $field) {
foreach (['filters', 'join_filters', 'group_bys', 'order_bys'] as $type) {
$logMetaData[$index]['is_' . $type] = FALSE;
}
$logMetaData[$index]['dbAlias'] = $this->_columns['log_civicrm_address']['alias'] . '.' . $field['name'];
$logMetaData[$index]['alias'] = $this->_columns['log_civicrm_address']['alias'] . '_' . $field['name'];
}
$this->_columns['log_civicrm_address']['metadata'] += $logMetaData;
$this->_columns['log_civicrm_address']['fields'] += $logMetaData;
$this->_columns['log_civicrm_address']['filters']['contact_id'] = $logMetaData['contact_id'];
......
......@@ -25,7 +25,10 @@ class CRM_Extendedreport_Form_Report_Contact_Extendedcontact extends CRM_Extende
);
$this->_columns['civicrm_contact']['fields']['id']['required'] = TRUE;
$this->_aggregateColumnHeaderFields = array(
'civicrm_contact_civireport:gender_id' => 'Gender',
'civicrm_contact:gender_id' => 'Gender',
);
$this->_aggregateRowFields = array(
'civicrm_contact:gender_id' => 'Gender',
);
parent::__construct();
}
......
......@@ -64,25 +64,23 @@ class CRM_Extendedreport_Form_Report_Contribute_BookkeepingExtended extends CRM_
+ $this->getColumns('FinancialTrxn', array(
'filters_defaults' => array('status_id' => array('IN' => array(1)),
)))
+ array(
'civicrm_entity_financial_trxn' => array(
'dao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
'fields' => array(
+ $this->buildColumns(
[
'amount' => array(
'title' => ts('Amount'),
'default' => TRUE,
'type' => CRM_Utils_Type::T_STRING,
'statistics' => array('sum'),
),
),
'filters' => array(
'amount' => array(
'title' => ts('Amount'),
'type' => CRM_Utils_Type::T_MONEY,
'operatorType' => CRM_Report_Form::OP_FLOAT,
'statistics' => ['sum' => ts('Total amount')],
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
'is_join_filters' => FALSE,
'table_name' => 'civicrm_entity_financial_trxn',
),
),
),
) + $this->getColumns('Batch', array(
], 'civicrm_entity_financial_trxn', 'CRM_Financial_DAO_EntityFinancialTrxn')
+ $this->getColumns('Batch', array(
'group_by' => TRUE,
'prefix_label' => ts('Batch '),
'filters' => TRUE,
......@@ -91,6 +89,7 @@ class CRM_Extendedreport_Form_Report_Contribute_BookkeepingExtended extends CRM_
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
CRM_Core_DAO::disableFullGroupByMode();
}
......@@ -342,7 +341,7 @@ class CRM_Extendedreport_Form_Report_Contribute_BookkeepingExtended extends CRM_
$this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field);
$this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
$this->_columnHeaders["{$tableName}_{$fieldName}"]['dbAlias'] = CRM_Utils_Array::value('dbAlias', $field);
$this->_selectAliases[] = $alias;
$this->_selectAliases[$alias] = $alias;
}
public function storeGroupByArray() {
......
<?php
// This file declares a managed database record of type "ReportTemplate".
// The record will be automatically inserted, updated, or deleted from the
// database as appropriate. For more details, see "hook_civicrm_managed" at:
// http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference
return array(
0 => array(
'name' => 'Extended Report - Contributions',
'entity' => 'ReportTemplate',
'params' => array(
'version' => 3,
'label' => 'Extended Report - Contributions',
'description' => 'Extended Report - Contributions',
'class_name' => 'CRM_Extendedreport_Form_Report_Contribute_Contributions',
'report_url' => 'contribution/contributions',
'component' => 'CiviContribute',
),
),
);
{*
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
......@@ -22,72 +23,78 @@
| 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-2015
*/
class CRM_Extendedreport_Form_Report_Contribute_Contributions extends CRM_Extendedreport_Form_Report_ExtendedReport {
<div id="report-tab-order-by-elements" class="civireport-criteria">
<table id="optionField">
<tr>
<th>&nbsp;</th>
<th> {ts}Column{/ts}</th>
<th> {ts}Order{/ts}</th>
<th> {ts}Section Header / Group By{/ts}</th>
<th> {ts}Page Break{/ts}</th>
</tr>
/**
* Can this report be used on a contact tab.
*
* The report must support contact_id in the url for this to work.
*
* @var bool
*/
protected $isSupportsContactTab = TRUE;
{section name=rowLoop start=1 loop=6}
{assign var=index value=$smarty.section.rowLoop.index}
<tr id="optionField_{$index}" class="form-item {cycle values="odd-row,even-row"}">
<td>
{if $index GT 1}
<a onclick="hideRow({$index}); return false;" name="orderBy_{$index}" href="#" class="form-link"><img src="{$config->resourceBase}i/TreeMinus.gif" class="action-icon" alt="{ts}hide field or section{/ts}"/></a>
{/if}
</td>
<td> {$form.order_bys.$index.column.html}</td>
<td> {$form.order_bys.$index.order.html}</td>
<td> {$form.order_bys.$index.section.html}</td>
<td> {$form.order_bys.$index.pageBreak.html}</td>
</tr>
{/section}
</table>
<div id="optionFieldLink" class="add-remove-link">
<a onclick="showHideRow(); return false;" name="optionFieldLink" href="#" class="form-link"><img src="{$config->resourceBase}i/TreePlus.gif" class="action-icon" alt="{ts}show field or section{/ts}"/>{ts}another column{/ts}</a>
</div>
<script type="text/javascript">
var showRows = new Array({$showBlocks});
var hideBlocks = new Array({$hideBlocks});
var rowcounter = 0;
{literal}
if (navigator.appName == "Microsoft Internet Explorer") {
for ( var count = 0; count < hideBlocks.length; count++ ) {
var r = document.getElementById(hideBlocks[count]);
r.style.display = 'none';
}
}
/**
* Add order bys for custom fields.
*
* @var bool
*/
protected $_customGroupOrderBy = TRUE;
// hide and display the appropriate blocks as directed by the php code
on_load_init_blocks( showRows, hideBlocks, '');
/**
* Add group bys for custom fields.
*
* @var bool
*/
protected $_customGroupGroupBy = TRUE;
cj('input[id^="order_by_section_"]').click(disPageBreak).each(disPageBreak);
/**
* @var array
*/
protected $_customGroupExtends = array('Contribution', 'Contact', 'Individual', 'Organization', 'Household');
function disPageBreak() {
if (!cj(this).prop('checked')) {
cj(this).parent('td').next('td').children('input[id^="order_by_pagebreak_"]').prop({checked: false, disabled: true});
}
else {
cj(this).parent('td').next('td').children('input[id^="order_by_pagebreak_"]').prop({disabled: false});
}
}
/**
* Support contact tabs by specifying which filter to map the contact id field to.
*
* @var string
*/
protected $contactIDField = 'contribution_contact_id';
function hideRow(i) {
showHideRow(i);
// clear values on hidden field, so they're not saved
cj('select#order_by_column_'+ i).val('');
cj('select#order_by_order_'+ i).val('ASC');
cj('input#order_by_section_'+ i).prop('checked', false);
cj('input#order_by_pagebreak_'+ i).prop('checked', false);
}
protected $_baseTable = 'civicrm_contribution';
{/literal}
</script>
</div>
protected $joinFiltersTab = TRUE;
/**
* Class constructor.
*/
public function __construct() {
$this->_columns = $this->getColumns('Contribution', ['group_by' => TRUE])
+ $this->getColumns('Contact', ['group_by' => TRUE])
+ $this->getColumns('Email', ['group_by' => TRUE])
+ $this->getColumns('Address', ['group_by' => TRUE])
+ $this->getColumns('Phone', ['group_by' => TRUE])
+ $this->getColumns('Website', ['group_by' => TRUE, 'join_filters' => TRUE]);
parent::__construct();
}
/**
* @return array
*/
function fromClauses() {
return array(
'contact_from_contribution',
'email_from_contact',
'phone_from_contact',
'address_from_contact',
'website_from_contact',
);
}
}
......@@ -55,7 +55,10 @@ class CRM_Extendedreport_Form_Report_Contribute_LoggingSummary extends CRM_Exten
$this->_columns['civicrm_contribution']['metadata']['log_user_id'] = array(
'title' => ts('Changed By'),
'alter_display' => 'alterContactID',
'name' => 'log_user_id',
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
'no_display' => FALSE,
);
$this->_columns['civicrm_contribution']['fields']['log_date'] = array(
......@@ -87,14 +90,27 @@ class CRM_Extendedreport_Form_Report_Contribute_LoggingSummary extends CRM_Exten
'title' => ts('Action'),
'type' => CRM_Utils_Type::T_STRING,
);
foreach ($this->_columns['civicrm_contribution']['metadata'] as $index => $field) {
if (!isset($field['dbAlias'])) {
$this->_columns['civicrm_contribution']['metadata'][$index]['dbAlias'] = 'contribution.' . $index;
}
if (!isset($field['alias'])) {
$this->_columns['civicrm_contribution']['metadata'][$index]['alias'] = 'contribution_' . $index;
}
foreach (['filters', 'group_bys', 'order_bys', 'join_filters'] as $type) {
if (!isset($this->_columns['civicrm_contribution']['metadata'][$index]['is_' . $type])) {
$this->_columns['civicrm_contribution']['metadata'][$index]['is_' . $type] = FALSE;
}
}
}
$this->_aliases[$this->_baseTable] = 'contribution';
parent::__construct();
}
/**
* @param $value
* @param $row
* @param $fieldname
* @param array $row
* @param string $fieldname
*
* @return mixed
*/
......
......@@ -31,7 +31,6 @@
* @copyright CiviCRM LLC (c) 2004-2015
*/
class CRM_Extendedreport_Form_Report_Contribute_Overview extends CRM_Extendedreport_Form_Report_ExtendedReport {
protected $_addressField = FALSE;
protected $_charts = array(
'' => 'Tabular',
......@@ -70,48 +69,11 @@ class CRM_Extendedreport_Form_Report_Contribute_Overview extends CRM_Extendedrep
asort($this->activeCampaigns);
}
$this->_columns = array(
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
'fields' => array_merge(
$this->getBasicContactFields(),
array(
'sort_name' => array(
'title' => ts('Contact Name'),
'no_repeat' => TRUE,
),
)
),
'grouping' => 'contact-fields',
'group_bys' => array(
'id' => array('title' => ts('Contact ID')),
'sort_name' => array(
'title' => ts('Contact Name'),
),
),
),
'civicrm_email' => array(
'dao' => 'CRM_Core_DAO_Email',
'fields' => array(
'email' => array(
'title' => ts('Email'),
'no_repeat' => TRUE,
),
),
'grouping' => 'contact-fields',
),
'civicrm_phone' => array(
'dao' => 'CRM_Core_DAO_Phone',
'fields' => array(
'phone' => array(
'title' => ts('Phone'),
'no_repeat' => TRUE,
),
),
'grouping' => 'contact-fields',
),
) + $this->getColumns('Contribution', array('group_by' => TRUE))
+ $this->getColumns('Address');
$this->_columns = $this->getColumns('Contact', array('group_by' => TRUE))
+ $this->getColumns('Email', array('group_by' => TRUE))
+ $this->getColumns('Phone', array('group_by' => TRUE))
+ $this->getColumns('Contribution', array('group_by' => TRUE))
+ $this->getColumns('Address');
// If we have a campaign, build out the relevant elements
if ($campaignEnabled && !empty($this->activeCampaigns)) {
......@@ -183,7 +145,7 @@ class CRM_Extendedreport_Form_Report_Contribute_Overview extends CRM_Extendedrep
ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
{$this->_aliases['civicrm_phone']}.is_primary = 1)";
if ($this->_addressField) {
if ($this->isTableSelected('civicrm_address')) {
$this->_from .= "
LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
ON {$this->_aliases['civicrm_contact']}.id =
......
......@@ -17,6 +17,7 @@ class CRM_Extendedreport_Form_Report_Event_EventOverview extends CRM_Extendedrep
public function __construct() {
$this->_columns = $this->getColumns('Event', array()) +
$this->getColumns('EventSummary');
$this->_whereClauses[] = 'event.is_template = 0';
parent::__construct();
}
......
......@@ -28,109 +28,35 @@ class CRM_Extendedreport_Form_Report_Pledge_Btbns extends CRM_Extendedreport_For
$date['minYear']++;
}
$this->_columns = array(
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
'grouping' => 'contact-field',
'fields' => array(
'display_name' => array(
'title' => ts('Donor Name'),
'default' => TRUE,
'required' => TRUE,
),
),
'filters' => array(
'sort_name' => array(
'title' => ts('Donor Name'),
'operator' => 'like',
),
),
),
'civicrm_email' => array(
'dao' => 'CRM_Core_DAO_Email',
'grouping' => 'contact-field',
'fields' => array(
'email' => array(
'title' => ts('Email'),
'default' => TRUE,
),
),
),
'civicrm_phone' => array(
'dao' => 'CRM_Core_DAO_Phone',
'grouping' => 'contact-field',
'fields' => array(
'phone' => array(
'title' => ts('Phone No'),
'default' => TRUE,
),
),
),
'civicrm_pledge' => array(
'dao' => 'CRM_Pledge_DAO_Pledge',
'fields' => array(
'contact_id' => array(
'title' => ts('contactId'),
'required' => TRUE,
'no_repeat' => TRUE,
'type' => CRM_Utils_Type::T_INT,
),
'amount' => array(
'title' => ts('Total Amount'),
'required' => TRUE,
'no_repeat' => TRUE,
'type' => CRM_Utils_Type::T_MONEY,
),
'start_date' => array(
'title' => ts('Start Date (within range)'),
'required' => TRUE,
'no_repeat' => TRUE,
'type' => CRM_Utils_Type::T_DATE,
),
),
'filters' => array(
'yid' => array(
'name' => 'start_date',
'title' => ts('Last Pledge Start Date'),
'type' => CRM_Utils_Type::T_DATE,
'operatorType' => CRM_Report_Form::OP_DATE,
'clause' => "pledge_civireport.contact_id IN
$this->_columns = $this->getColumns('Contact')
+ $this->getColumns('Email')
+ $this->getColumns('Phone')
+ $this->getColumns('Pledge');
$this->_columns['civicrm_pledge']['filters']['yid'] =
$this->_columns['civicrm_pledge']['metadata']['yid'] = [
'name' => 'start_date',
'title' => ts('Last Pledge Start Date'),
'type' => CRM_Utils_Type::T_DATE,
'operatorType' => CRM_Report_Form::OP_DATE,
'clause' => "pledge.contact_id IN
(SELECT distinct pledge.contact_id FROM civicrm_pledge pledge
WHERE pledge.start_date BETWEEN '\$from' AND '\$to' AND pledge.is_test = 0
)
AND pledge_civireport.contact_id NOT IN
AND pledge.contact_id NOT IN
(SELECT distinct pledge.contact_id FROM civicrm_pledge pledge
WHERE pledge.start_date >= ('\$to') AND pledge.is_test = 0) ",
),
'status_id' => array(
'title' => 'Pledge Status',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'type' => CRM_Utils_Type::T_INT,
'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
'default' => array(
'1',
),
),
),
),
'civicrm_group' => array(
'dao' => 'CRM_Contact_DAO_GroupContact',
'alias' => 'cgroup',
'filters' => array(
'gid' => array(
'name' => 'group_id',
'title' => ts('Group'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'group' => TRUE,
'type' => CRM_Utils_Type::T_INT,
'options' => CRM_Core_PseudoConstant::group()
)
)
)
);
'is_filters' => TRUE,
'is_join_filters' => TRUE,
'is_fields' => FALSE,
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
'default' => date('Y'),
];
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
CRM_Core_DAO::disableFullGroupByMode();
}
function select() {
......@@ -244,7 +170,6 @@ class CRM_Extendedreport_Form_Report_Pledge_Btbns extends CRM_Extendedreport_For
while ($dao->fetch()) {
$contactIds[] = $dao->cid;
}
$dao->free();
$this->setPager();
}
if (!empty($contactIds) || CRM_Utils_Array::value('charts', $this->_params)) {
......@@ -279,7 +204,6 @@ class CRM_Extendedreport_Form_Report_Pledge_Btbns extends CRM_Extendedreport_For
$rows[$dao->civicrm_pledge_contact_id]['civicrm_life_time_total'] = $dao->civicrm_pledge_amount;
}
}
$dao->free();
}
$this->formatDisplay($rows, FALSE);
......
......@@ -7,6 +7,7 @@
* $Id$
*
*/
use CRM_Extendedreport_ExtensionUtil as E;
class CRM_Extendedreport_Form_Report_Pledge_Detail extends CRM_Extendedreport_Form_Report_ExtendedReport {