Commit 312b6572 authored by eileen's avatar eileen
Browse files

Update extended report

parent fd85c257
......@@ -5,6 +5,7 @@
*/
class CRM_Extendedreport_Form_Report_ActivityPivot extends CRM_Extendedreport_Form_Report_ExtendedReport {
protected $_baseTable = 'civicrm_activity';
protected $_customGroupExtends = ['Activity'];
protected $skipACL = FALSE;
protected $isPivot = TRUE;
protected $_customGroupAggregates = TRUE;
......
......@@ -16,16 +16,12 @@ class CRM_Extendedreport_Form_Report_Case_CasePivot extends CRM_Extendedreport_F
protected $_potentialCriteria = array();
protected $isPivot = TRUE;
protected $_noFields = TRUE;
protected $_customGroupExtends = ['Case'];
/**
* Class constructor.
*/
public function __construct() {
$this->_customGroupExtended['civicrm_case'] = array(
'extends' => array('Case'),
'filters' => TRUE,
'title' => ts('Case'),
);
$this->_columns = $this->getColumns('Case', array(
'fields' => FALSE,
......
......@@ -15,6 +15,7 @@ class CRM_Extendedreport_Form_Report_Case_CaseWithActivityPivot extends CRM_Exte
public $_drilldownReport = array();
protected $isPivot = TRUE;
protected $_noFields = TRUE;
protected $_customGroupExtends = ['Case', 'Activity'];
/**
* PreConstrain means the query gets run twice - the first time for generating temp tables
* which go in the from the second time around
......@@ -34,17 +35,6 @@ class CRM_Extendedreport_Form_Report_Case_CaseWithActivityPivot extends CRM_Exte
*
*/
public function __construct() {
$this->_customGroupExtended['civicrm_case'] = array(
'extends' => array('Case'),
'filters' => TRUE,
'title' => ts('Case'),
);
$this->_customGroupExtended['civicrm_activity'] = array(
'extends' => array('Activity'),
'filters' => TRUE,
'title' => ts('Activity'),
);
$this->_columns = $this->getColumns('Case', array(
'fields' => FALSE,
)
......
......@@ -6,6 +6,9 @@
* Time: 1:05 AM
*/
use CRM_Extendedreport_ExtensionUtil as E;
/**
* Trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait
*
......@@ -43,7 +46,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
$spec = [
'id' => [
'name' => 'id',
'title' => ts('Activity ID'),
'title' => E::ts('Activity ID'),
'is_group_bys' => $options['group_by'],
'is_fields' => TRUE,
],
......@@ -52,18 +55,24 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'required' => FALSE,
],
'activity_type_id' => [
'title' => ts('Activity Type'),
'title' => E::ts('Activity Type'),
'alter_display' => 'alterActivityType',
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE),
'options' => $this->_getOptions('activity', 'activity_type_id'),
'name' => 'activity_type_id',
'type' => CRM_Utils_Type::T_INT,
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
'options' => $this->_getOptions('activity', 'activity_type_id'),
],
],
'subject' => [
'title' => ts('Subject'),
'title' => E::ts('Subject'),
'name' => 'subject',
'is_fields' => TRUE,
'is_filters' => TRUE,
......@@ -75,7 +84,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
],
'activity_date_time' => [
'title' => ts('Activity Date'),
'title' => E::ts('Activity Date'),
'default' => TRUE,
'name' => 'activity_date_time',
'operatorType' => CRM_Report_Form::OP_DATE,
......@@ -85,7 +94,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_order_bys' => TRUE,
],
'status_id' => [
'title' => ts('Activity Status'),
'title' => E::ts('Activity Status'),
'name' => 'status_id',
'type' => CRM_Utils_Type::T_STRING,
'alter_display' => 'alterPseudoConstant',
......@@ -102,21 +111,26 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
],
],
'duration' => [
'title' => ts('Duration (sum for all contacts)'),
'title' => E::ts('Duration (sum for all contacts)'),
'type' => CRM_Utils_Type::T_INT,
'statistics' => [
'sum' => ts('Total Duration'),
'sum' => E::ts('Total Duration'),
],
'is_fields' => TRUE,
],
'duration_each' => [
'title' => ts('Duration (for each contact)'),
'title' => E::ts('Duration (for each contact)'),
'name' => 'duration',
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
],
],
'details' => [
'title' => ts('Activity Details'),
'title' => E::ts('Activity Details'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'type' => CRM_Utils_Type::T_TEXT,
......@@ -125,10 +139,37 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'id_field' => 'id',
'entity' => 'activity',
],
],
'location' => [
'title' => E::ts('Location'),
'type' => CRM_Utils_Type::T_STRING,
'is_filters' => TRUE,
'is_fields' => TRUE,
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
],
],
'priority_id' => [
'title' => E::ts('Priority'),
'type' => CRM_Utils_Type::T_STRING,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'alter_display' => 'alterPseudoConstant',
'options' => $this->_getOptions('activity', 'priority_id'),
'is_filters' => TRUE,
'is_fields' => TRUE,
'is_group_bys' => TRUE,
'is_order_bys' => TRUE,
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
'options' => $this->_getOptions('activity', 'priority_id'),
],
],
'result' => [
'title' => ts('Activity Result'),
'title' => E::ts('Activity Result'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'type' => CRM_Utils_Type::T_TEXT,
......@@ -141,7 +182,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_current_revision' => [
'type' => CRM_Report_Form::OP_INT,
'operatorType' => CRM_Report_Form::OP_SELECT,
'title' => ts("Current Revision"),
'title' => E::ts("Current Revision"),
'name' => 'is_current_revision',
'options' => ['1' => 'Yes', '0' => 'No',],
'is_filters' => TRUE,
......@@ -149,7 +190,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_deleted' => [
'type' => CRM_Report_Form::OP_INT,
'operatorType' => CRM_Report_Form::OP_SELECT,
'title' => ts("Is activity deleted"),
'title' => E::ts("Is activity deleted"),
'name' => 'is_deleted',
'options' => ['0' => 'No', '1' => 'Yes',],
'is_filters' => TRUE,
......@@ -176,18 +217,18 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'civicrm_case' => [
'fields' => [
'id' => [
'title' => ts('Case ID'),
'title' => E::ts('Case ID'),
'name' => 'id',
'is_fields' => TRUE,
],
'subject' => [
'title' => ts('Case Subject'),
'title' => E::ts('Case Subject'),
'default' => TRUE,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'status_id' => [
'title' => ts('Case Status'),
'title' => E::ts('Case Status'),
'default' => TRUE,
'name' => 'status_id',
'is_fields' => TRUE,
......@@ -197,7 +238,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'type' => CRM_Utils_Type::T_INT,
],
'case_type_id' => [
'title' => ts('Case Type'),
'title' => E::ts('Case Type'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
......@@ -206,7 +247,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'type' => CRM_Utils_Type::T_INT,
],
'start_date' => [
'title' => ts('Case Start Date'),
'title' => E::ts('Case Start Date'),
'name' => 'start_date',
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE,
......@@ -214,7 +255,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_filters' => TRUE,
],
'end_date' => [
'title' => ts('Case End Date'),
'title' => E::ts('Case End Date'),
'name' => 'end_date',
'is_fields' => TRUE,
'is_filters' => TRUE,
......@@ -223,7 +264,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
],
'is_deleted' => [
'name' => 'is_deleted',
'title' => ts('Case Deleted?'),
'title' => E::ts('Case Deleted?'),
'type' => CRM_Utils_Type::T_BOOLEAN,
'is_fields' => TRUE,
'is_filters' => TRUE,
......@@ -269,14 +310,14 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
$spec = [
$options['prefix'] . 'display_name' => [
'name' => 'display_name',
'title' => ts($options['prefix_label'] . 'Contact Name'),
'title' => E::ts($options['prefix_label'] . 'Contact Name'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
],
$options['prefix'] . 'contact_id' => [
'name' => 'id',
'title' => ts($options['prefix_label'] . 'Contact ID'),
'title' => E::ts($options['prefix_label'] . 'Contact ID'),
'alter_display' => 'alterContactID',
'type' => CRM_Utils_Type::T_INT,
'is_order_bys' => TRUE,
......@@ -287,19 +328,19 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
],
$options['prefix'] . 'external_identifier' => [
'name' => 'external_identifier',
'title' => ts($options['prefix_label'] . 'External ID'),
'title' => E::ts($options['prefix_label'] . 'External ID'),
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
],
$options['prefix'] . 'sort_name' => [
'name' => 'sort_name',
'title' => ts($options['prefix_label'] . 'Contact Name (in sort format)'),
'title' => E::ts($options['prefix_label'] . 'Contact Name (in sort format)'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
],
$options['prefix'] . 'contact_type' => [
'title' => ts($options['prefix_label'] . 'Contact Type'),
'title' => E::ts($options['prefix_label'] . 'Contact Type'),
'name' => 'contact_type',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contact_BAO_Contact::buildOptions('contact_type'),
......@@ -308,7 +349,7 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_group_bys' => TRUE,
],
$options['prefix'] . 'contact_sub_type' => [
'title' => ts($options['prefix_label'] . 'Contact Sub Type'),
'title' => E::ts($options['prefix_label'] . 'Contact Sub Type'),
'name' => 'contact_sub_type',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contact_BAO_Contact::buildOptions('contact_sub_type'),
......@@ -320,33 +361,33 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
$individualFields = [
$options['prefix'] . 'first_name' => [
'name' => 'first_name',
'title' => ts($options['prefix_label'] . 'First Name'),
'title' => E::ts($options['prefix_label'] . 'First Name'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
],
$options['prefix'] . 'middle_name' => [
'name' => 'middle_name',
'title' => ts($options['prefix_label'] . 'Middle Name'),
'title' => E::ts($options['prefix_label'] . 'Middle Name'),
'is_fields' => TRUE,
],
$options['prefix'] . 'last_name' => [
'name' => 'last_name',
'title' => ts($options['prefix_label'] . 'Last Name'),
'title' => E::ts($options['prefix_label'] . 'Last Name'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
],
$options['prefix'] . 'nick_name' => [
'name' => 'nick_name',
'title' => ts($options['prefix_label'] . 'Nick Name'),
'title' => E::ts($options['prefix_label'] . 'Nick Name'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
],
$options['prefix'] . 'gender_id' => [
'name' => 'gender_id',
'title' => ts($options['prefix_label'] . 'Gender'),
'title' => E::ts($options['prefix_label'] . 'Gender'),
'options' => CRM_Contact_BAO_Contact::buildOptions('gender_id'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'alter_display' => 'alterGenderID',
......@@ -354,14 +395,14 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_filters' => TRUE,
],
'birth_date' => [
'title' => ts($options['prefix_label'] . 'Birth Date'),
'title' => E::ts($options['prefix_label'] . 'Birth Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'age' => [
'title' => ts($options['prefix_label'] . 'Age'),
'title' => E::ts($options['prefix_label'] . 'Age'),
'dbAlias' => 'TIMESTAMPDIFF(YEAR, ' . $tableAlias . '.birth_date, CURDATE())',
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
......@@ -406,14 +447,14 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
$options = array_merge($defaultOptions, $options);
$activityFields['civicrm_activity']['fields'] = [
'activity_type_id' => [
'title' => ts('Latest Activity Type'),
'title' => E::ts('Latest Activity Type'),
'default' => FALSE,
'type' => CRM_Utils_Type::T_STRING,
'alter_display' => 'alterActivityType',
'is_fields' => TRUE,
],
'activity_date_time' => [
'title' => ts('Latest Activity Date'),
'title' => E::ts('Latest Activity Date'),
'default' => FALSE,
'is_fields' => TRUE,
],
......@@ -421,4 +462,147 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
return $this->buildColumns($activityFields['civicrm_activity']['fields'], $options['prefix'] . 'civicrm_activity', 'CRM_Activity_DAO_Activity');
}
/**
* @param array $options
*
* @return array
*/
function getContributionRecurColumns($options = []) {
$spec = [
'id' => [
'is_fields' => TRUE,
'is_filters' => TRUE,
'type' => CRM_Utils_Type::T_INT,
'statistics' => ['count' => E::ts('Numer of recurring profiles')],
],
'payment_processor_id' => [
'title' => E::ts('Payment Processor'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'alter_display' => 'alterPseudoConstant',
'options' => CRM_Contribute_BAO_ContributionRecur::buildOptions('payment_processor_id', 'get'),
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
'is_order_bys' => TRUE,
],
'currency' => [
'title' => E::ts("Currency"),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Core_OptionGroup::values('currencies_enabled'),
'default' => NULL,
'type' => CRM_Utils_Type::T_STRING,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'contribution_status_id' => [
'title' => E::ts('Recurring Contribution Status'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
'default' => [5],
'type' => CRM_Utils_Type::T_INT,
'is_group_bys' => TRUE,
'is_order_bys' => TRUE,
],
'frequency_interval' => [
'title' => E::ts('Frequency interval'),
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
'is_filters' => TRUE
],
'frequency_unit' => [
'title' => E::ts('Frequency unit'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Core_OptionGroup::values('recur_frequency_units'),
'type' => CRM_Utils_Type::T_STRING,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'amount' => [
'title' => E::ts('Installment Amount'),
'type' => CRM_Utils_Type::T_MONEY,
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
'is_order_bys' => TRUE,
],
'installments' => [
'title' => E::ts('Installments'),
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'start_date' => [
'title' => E::ts('Start Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'create_date' => [
'title' => E::ts('Create Date'),
'is_fields' => TRUE,
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'is_filters' => TRUE,
],
'modified_date' => [
'title' => E::ts('Modified Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'cancel_date' => [
'title' => E::ts('Cancel Date'),
'is_fields' => TRUE,
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'is_filters' => TRUE,
],
'cancel_reason' => [
'title' => E::ts('Cancellation Reason'),
'operatorType' => CRM_Report_Form::OP_STRING,
'type' => CRM_Utils_Type::T_STRING,
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
'is_order_bys' => TRUE,
],
'end_date' => [
'title' => E::ts('End Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'next_sched_contribution_date' => [
'title' => E::ts('Next Scheduled Contribution Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'is_fields' => TRUE,
'is_filters' => TRUE,
],
'failure_count' => [
'title' => E::ts('Failure Count'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'type' => CRM_Utils_Type::T_INT,
],
'failure_retry_date' => [
'title' => E::ts('Failure Retry Date'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
],
'financial_type_id' => [
'title' => E::ts('Financial Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(),
'type' => CRM_Utils_Type::T_INT,
],
];
return $this->buildColumns($spec, $options['prefix'] . 'civicrm_contribution_recur', 'CRM_Contribute_BAO_ContributionRecur', NULL, $this->getDefaultsFromOptions($options), $options);
}
}
......@@ -12,7 +12,7 @@ class CRM_Extendedreport_Form_Report_Contact_Extendedcontact extends CRM_Extende
protected $_customGroupAggregates = TRUE;
protected $isPivot = TRUE;
protected $_noFields = TRUE;
protected $_customGroupExtends = ['Contact', 'Individual', 'Household', 'Organization'];
/**
* Class constructor.
......
......@@ -14,6 +14,7 @@ class CRM_Extendedreport_Form_Report_Contribute_ContributionPivot extends CRM_Ex
protected $isPivot = TRUE;
protected $_potentialCriteria = array();
protected $_noFields = TRUE;
protected $_customGroupExtends = ['Contribution', 'Contact', 'Individual', 'Household', 'Organization'];
/**
* Class constructor.
......
<?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 [
0 => [
'name' => 'Extended Report - Recurring Contribution Pivot Chart',
'entity' => 'ReportTemplate',
'params' => [
'version' => 3,
'label' => 'Extended Report - Recurring Contribution Pivot Chart',
'description' => 'Extended Report - Contribution Recur Pivot Chart',
'class_name' => 'CRM_Extendedreport_Form_Report_Contribute_ContributionRecurPivot',