Commit fde96e00 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

Update extendedreports ext

parent ee525db0
......@@ -4,7 +4,6 @@
* Class CRM_Extendedreport_Form_Report_ActivityExtended
*/
class CRM_Extendedreport_Form_Report_ActivityEditable extends CRM_Extendedreport_Form_Report_ExtendedReport {
//todo move def to getActivityColumns
/**
* @var array
*/
......@@ -26,13 +25,10 @@ class CRM_Extendedreport_Form_Report_ActivityEditable extends CRM_Extendedreport
* Class constructor.
*/
public function __construct() {
$this->_columns = $this->getColumns('Activity', array('fields_defaults' => array('activity_type_id', 'details', 'subject')))
+ $this->getColumns('Contact', array('prefix' => 'target_'));
$this->_columns['civicrm_activity']['fields']['id'] = array(
'title' => 'id',
'required' => TRUE,
'type' => CRM_Utils_Type::T_INT,
);
$this->_columns = $this->getColumns('Activity', ['fields_defaults' => ['activity_type_id', 'details', 'subject']])
+ $this->getColumns('Contact', ['prefix' => 'target_']);
$this->_columns['civicrm_activity']['metadata']['activity_id']['required'] = TRUE;
$this->_columns['civicrm_activity']['metadata']['activity_id']['no_display'] = TRUE;
parent::__construct();
}
......
......@@ -11,37 +11,25 @@ class CRM_Extendedreport_Form_Report_ActivityPivot extends CRM_Extendedreport_Fo
protected $_aggregatesIncludeNULL = TRUE;
protected $_aggregatesAddTotal = TRUE;
protected $_rollup = 'WITH ROLLUP';
public $_drilldownReport = array();
protected $_potentialCriteria = array();
public $_drilldownReport = [];
protected $_potentialCriteria = [];
protected $_noFields = TRUE;
/**
* Class constructor.
*/
public function __construct() {
$this->_customGroupExtended['civicrm_activity'] = array(
'extends' => array('Activity'),
$this->_customGroupExtended['civicrm_activity'] = [
'extends' => ['Activity'],
'filters' => TRUE,
'title' => ts('Activity'),
);
];
$this->_columns = $this->getColumns('Activity', array(
$this->_columns = $this->getColumns('Activity', [
'fields' => FALSE,
)
]
)// + $this->getColumns('Contact', array())
;
$this->_aggregateRowFields = array(
'activity:activity_activity_type_id' => 'Activity Type',
'activity:activity_status_id' => 'Activity Status',
'activity:activity_result' => 'Activity Result',
'activity:activity_subject' => 'Activity Subject',
// 'civicrm_contact_civireport:gender_id' => 'Gender',
);
$this->_aggregateColumnHeaderFields = array(
'activity:activity_activity_type_id' => 'Activity Type',
'activity:activity_status_id' => 'Activity Status',
);
parent::__construct();
}
......@@ -51,6 +39,6 @@ class CRM_Extendedreport_Form_Report_ActivityPivot extends CRM_Extendedreport_Fo
* @return array
*/
public function fromClauses() {
return array();
return [];
}
}
......@@ -32,6 +32,8 @@ class CRM_Extendedreport_Form_Report_Campaign_CampaignProgressReport extends CRM
'is_group_bys' => TRUE,
'is_order_bys' => FALSE,
'is_join_filters' => FALSE,
'is_aggregate_columns' => FALSE,
'is_aggregate_rows' => FALSE,
'options' => $this->_getOptions('Contribution', 'financial_type_id'),
],
'total_amount' => [
......@@ -44,6 +46,8 @@ class CRM_Extendedreport_Form_Report_Campaign_CampaignProgressReport extends CRM
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
'is_join_filters' => FALSE,
'is_aggregate_columns' => FALSE,
'is_aggregate_rows' => FALSE,
],
'paid_amount' => [
'title' => ts('Amount received'),
......@@ -55,6 +59,8 @@ class CRM_Extendedreport_Form_Report_Campaign_CampaignProgressReport extends CRM
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
'is_join_filters' => FALSE,
'is_aggregate_columns' => FALSE,
'is_aggregate_rows' => FALSE,
],
'balance_amount' => [
'title' => ts('Amount outstanding'),
......@@ -66,6 +72,8 @@ class CRM_Extendedreport_Form_Report_Campaign_CampaignProgressReport extends CRM
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
'is_join_filters' => FALSE,
'is_aggregate_columns' => FALSE,
'is_aggregate_rows' => FALSE,
],
'is_pledge' => [
'title' => ts('Type'),
......@@ -88,6 +96,8 @@ class CRM_Extendedreport_Form_Report_Campaign_CampaignProgressReport extends CRM
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
'is_join_filters' => FALSE,
'is_aggregate_columns' => FALSE,
'is_aggregate_rows' => FALSE,
],
'effective_date' => [
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
......@@ -99,6 +109,8 @@ class CRM_Extendedreport_Form_Report_Campaign_CampaignProgressReport extends CRM
'is_group_bys' => FALSE,
'is_order_bys' => FALSE,
'is_join_filters' => FALSE,
'is_aggregate_columns' => FALSE,
'is_aggregate_rows' => FALSE,
],
];
......
......@@ -44,13 +44,6 @@ class CRM_Extendedreport_Form_Report_Case_ActivityPivot extends CRM_Extendedrepo
$this->_columns['civicrm_contact']['fields']['gender_id']['no_display'] = TRUE;
$this->_columns['civicrm_contact']['fields']['gender_id']['title'] = 'Gender';
$this->_aggregateRowFields = array(
'case_civireport:id' => 'Case',
'civicrm_contact_civireport:gender_id' => 'Gender',
);
$this->_aggregateColumnHeaderFields = array(
'civicrm_contact_civireport:gender_id' => 'Gender',
);
$this->_tagFilter = TRUE;
$this->_groupFilter = TRUE;
parent::__construct();
......
......@@ -40,27 +40,20 @@ class CRM_Extendedreport_Form_Report_Case_CasePivot extends CRM_Extendedreport_F
$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],
['is_fields' => FALSE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, 'is_order_bys' => FALSE, 'is_join_filters' => FALSE, 'is_aggregate_columns' => 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],
['is_fields' => FALSE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, 'is_order_bys' => FALSE, 'is_join_filters' => FALSE,
'is_aggregate_columns' => TRUE],
$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],
['is_fields' => FALSE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, 'is_order_bys' => FALSE, 'is_join_filters' => FALSE,
'is_aggregate_columns' => FALSE],
$this->_columns['civicrm_case']['filters']['case_civireport_is_deleted']
);
$this->_aggregateRowFields = array(
'case_civireport:id' => 'Case',
'case_civireport:status_id' => 'Case Status',
'civicrm_contact:gender_id' => 'Gender',
);
$this->_aggregateColumnHeaderFields = array(
'civicrm_contact:gender_id' => 'Gender',
'case_civireport:status_id' => 'Case Status',
);
$this->_tagFilter = TRUE;
$this->_groupFilter = TRUE;
parent::__construct();
......
......@@ -61,13 +61,6 @@ class CRM_Extendedreport_Form_Report_Case_CaseWithActivityPivot extends CRM_Exte
$this->_columns['civicrm_contact']['fields']['gender_id']['no_display'] = TRUE;
$this->_columns['civicrm_contact']['fields']['gender_id']['title'] = 'Gender';
$this->_aggregateRowFields = array(
'case_civireport:id' => 'Case',
'civicrm_contact_civireport:gender_id' => 'Gender',
);
$this->_aggregateColumnHeaderFields = array(
'civicrm_contact_civireport:gender_id' => 'Gender',
);
$this->_tagFilter = TRUE;
$this->_groupFilter = TRUE;
parent::__construct();
......
......@@ -23,34 +23,35 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
*
* @return array
*/
function getActivityColumns($options = array()) {
$defaultOptions = array(
function getActivityColumns($options = []) {
$defaultOptions = [
'prefix' => '',
'prefix_label' => '',
'fields' => TRUE,
'group_by' => FALSE,
'order_by' => TRUE,
'filters' => TRUE,
'fields_defaults' => array(),
'filters_defaults' => array(),
'group_bys_defaults' => array(),
'order_by_defaults' => array(),
);
'fields_defaults' => [],
'filters_defaults' => [],
'group_bys_defaults' => [],
'order_by_defaults' => [],
];
$options = array_merge($defaultOptions, $options);
$defaults = $this->getDefaultsFromOptions($options);
$spec = array(
'id' => array(
'no_display' => TRUE,
'required' => TRUE,
$spec = [
'id' => [
'name' => 'id',
'title' => ts('Activity ID'),
'is_group_bys' => $options['group_by'],
),
'source_record_id' => array(
'is_fields' => TRUE,
],
'source_record_id' => [
'no_display' => TRUE,
'required' => FALSE,
),
'activity_type_id' => array(
],
'activity_type_id' => [
'title' => ts('Activity Type'),
'alter_display' => 'alterActivityType',
'is_fields' => TRUE,
......@@ -60,20 +61,20 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE),
'name' => 'activity_type_id',
'type' => CRM_Utils_Type::T_INT,
),
'subject' => array(
],
'subject' => [
'title' => ts('Subject'),
'name' => 'subject',
'is_fields' => TRUE,
'is_filters' => TRUE,
'crm_editable' => array(
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
),
],
),
'activity_date_time' => array(
],
'activity_date_time' => [
'title' => ts('Activity Date'),
'default' => TRUE,
'name' => 'activity_date_time',
......@@ -82,8 +83,8 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
),
'status_id' => array(
],
'status_id' => [
'title' => ts('Activity Status'),
'name' => 'status_id',
'type' => CRM_Utils_Type::T_STRING,
......@@ -93,68 +94,68 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_order_bys' => TRUE,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Core_PseudoConstant::activityStatus(),
'crm_editable' => array(
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
'options' => $this->_getOptions('activity', 'activity_status_id'),
),
),
'duration' => array(
],
],
'duration' => [
'title' => ts('Duration (sum for all contacts)'),
'type' => CRM_Utils_Type::T_INT,
'statistics' => array(
'sum' => ts('Total Duration')
),
'statistics' => [
'sum' => ts('Total Duration'),
],
'is_fields' => TRUE,
),
'duration_each' => array(
],
'duration_each' => [
'title' => ts('Duration (for each contact)'),
'name' => 'duration',
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
),
'details' => array(
],
'details' => [
'title' => ts('Activity Details'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'type' => CRM_Utils_Type::T_TEXT,
'crm_editable' => array(
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
),
],
),
'result' => array(
],
'result' => [
'title' => ts('Activity Result'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'type' => CRM_Utils_Type::T_TEXT,
'crm_editable' => array(
'crm_editable' => [
'id_table' => 'civicrm_activity',
'id_field' => 'id',
'entity' => 'activity',
),
),
'is_current_revision' => array(
],
],
'is_current_revision' => [
'type' => CRM_Report_Form::OP_INT,
'operatorType' => CRM_Report_Form::OP_SELECT,
'title' => ts("Current Revision"),
'name' => 'is_current_revision',
'options' => array('1' => 'Yes', '0' => 'No',),
'options' => ['1' => 'Yes', '0' => 'No',],
'is_filters' => TRUE,
),
'is_deleted' => array(
],
'is_deleted' => [
'type' => CRM_Report_Form::OP_INT,
'operatorType' => CRM_Report_Form::OP_SELECT,
'title' => ts("Is activity deleted"),
'name' => 'is_deleted',
'options' => array('0' => 'No', '1' => 'Yes',),
'options' => ['0' => 'No', '1' => 'Yes',],
'is_filters' => TRUE,
),
],
);
];
return $this->buildColumns($spec, $options['prefix'] . 'civicrm_activity', 'CRM_Activity_DAO_Activity', NULL, $defaults, $options);
}
......@@ -168,24 +169,24 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
function getCaseColumns($options) {
$config = CRM_Core_Config::singleton();
if (!in_array('CiviCase', $config->enableComponents)) {
return array('civicrm_case' => array('fields' => array(), 'metadata' => array()));
return ['civicrm_case' => ['fields' => [], 'metadata' => []]];
}
$spec = array(
'civicrm_case' => array(
'fields' => array(
'id' => array(
$spec = [
'civicrm_case' => [
'fields' => [
'id' => [
'title' => ts('Case ID'),
'name' => 'id',
'is_fields' => TRUE,
),
'subject' => array(
],
'subject' => [
'title' => ts('Case Subject'),
'default' => TRUE,
'is_fields' => TRUE,
'is_filters' => TRUE,
),
'status_id' => array(
],
'status_id' => [
'title' => ts('Case Status'),
'default' => TRUE,
'name' => 'status_id',
......@@ -194,8 +195,8 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Case_BAO_Case::buildOptions('case_status_id'),
'type' => CRM_Utils_Type::T_INT,
),
'case_type_id' => array(
],
'case_type_id' => [
'title' => ts('Case Type'),
'is_fields' => TRUE,
'is_filters' => TRUE,
......@@ -203,36 +204,36 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'options' => CRM_Case_BAO_Case::buildOptions('case_type_id'),
'name' => 'case_type_id',
'type' => CRM_Utils_Type::T_INT,
),
'start_date' => array(
],
'start_date' => [
'title' => ts('Case Start Date'),
'name' => 'start_date',
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE,
'is_fields' => TRUE,
'is_filters' => TRUE,
),
'end_date' => array(
],
'end_date' => [
'title' => ts('Case End Date'),
'name' => 'end_date',
'is_fields' => TRUE,
'is_filters' => TRUE,
'operatorType' => CRM_Report_Form::OP_DATE,
'type' => CRM_Utils_Type::T_DATE,
),
'is_deleted' => array(
],
'is_deleted' => [
'name' => 'is_deleted',
'title' => ts('Case Deleted?'),
'type' => CRM_Utils_Type::T_BOOLEAN,
'is_fields' => TRUE,
'is_filters' => TRUE,
'operatorType' => CRM_Report_Form::OP_SELECT,
'options' => array('' => '--select--') + CRM_Case_BAO_Case::buildOptions('is_deleted'),
)
)
),
'options' => ['' => '--select--'] + CRM_Case_BAO_Case::buildOptions('is_deleted'),
],
],
],
);
];
// Case is a special word in mysql so pass an alias to prevent it from using case.
return $this->buildColumns($spec['civicrm_case']['fields'], $options['prefix'] . 'civicrm_case', 'CRM_Case_DAO_Case', 'case_civireport');
}
......@@ -242,21 +243,21 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
*
* @return array
*/
function getContactColumns($options = array()) {
$defaultOptions = array(
function getContactColumns($options = []) {
$defaultOptions = [
'prefix' => '',
'prefix_label' => '',
'group_by' => TRUE,
'order_by' => TRUE,
'filters' => TRUE,
'fields' => TRUE,
'custom_fields' => array('Individual', 'Contact', 'Organization'),
'fields_defaults' => array('display_name', 'id'),
'filters_defaults' => array(),
'group_bys_defaults' => array(),
'order_by_defaults' => array('sort_name ASC'),
'custom_fields' => ['Individual', 'Contact', 'Organization'],
'fields_defaults' => ['display_name', 'id'],
'filters_defaults' => [],
'group_bys_defaults' => [],
'order_by_defaults' => ['sort_name ASC'],
'contact_type' => NULL,
);
];
$options = array_merge($defaultOptions, $options);
$orgOnly = FALSE;
......@@ -265,13 +266,15 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
}
$tableAlias = $options['prefix'] . 'civicrm_contact';
$spec = array(
$options['prefix'] . 'display_name' => array(
$spec = [
$options['prefix'] . 'display_name' => [
'name' => 'display_name',
'title' => ts($options['prefix_label'] . 'Contact Name'),
'is_fields' => TRUE,
),
$options['prefix'] . 'contact_id' => array(
'is_filters' => TRUE,
'is_order_bys' => TRUE,
],
$options['prefix'] . 'contact_id' => [
'name' => 'id',
'title' => ts($options['prefix_label'] . 'Contact ID'),
'alter_display' => 'alterContactID',
......@@ -281,21 +284,21 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_contact_filter' => TRUE,
),
$options['prefix'] . 'external_identifier' => array(
],
$options['prefix'] . 'external_identifier' => [
'name' => 'external_identifier',
'title' => ts($options['prefix_label'] . 'External ID'),
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
),
$options['prefix'] . 'sort_name' => array(
],
$options['prefix'] . 'sort_name' => [
'name' => 'sort_name',
'title' => ts($options['prefix_label'] . 'Contact Name (in sort format)'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
),
$options['prefix'] . 'contact_type' => array(
],
$options['prefix'] . 'contact_type' => [
'title' => ts($options['prefix_label'] . 'Contact Type'),
'name' => 'contact_type',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
......@@ -303,8 +306,8 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
),
$options['prefix'] . 'contact_sub_type' => array(
],
$options['prefix'] . 'contact_sub_type' => [
'title' => ts($options['prefix_label'] . 'Contact Sub Type'),
'name' => 'contact_sub_type',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
......@@ -312,36 +315,36 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
),
);
$individualFields = array(
$options['prefix'] . 'first_name' => array(
],
];
$individualFields = [
$options['prefix'] . 'first_name' => [
'name' => 'first_name',
'title' => ts($options['prefix_label'] . 'First Name'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
),
$options['prefix'] . 'middle_name' => array(
],
$options['prefix'] . 'middle_name' => [
'name' => 'middle_name',
'title' => ts($options['prefix_label'] . 'Middle Name'),
'is_fields' => TRUE,
),
$options['prefix'] . 'last_name' => array(
],
$options['prefix'] . 'last_name' => [
'name' => 'last_name',
'title' => ts($options['prefix_label'] . 'Last Name'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
),
$options['prefix'] . 'nick_name' => array(
],
$options['prefix'] . 'nick_name' => [
'name' => 'nick_name',
'title' => ts($options['prefix_label'] . 'Nick Name'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
),
$options['prefix'] . 'gender_id' => array(
],
$options['prefix'] . 'gender_id' => [
'name' => 'gender_id',
'title' => ts($options['prefix_label'] . 'Gender'),
'options' => CRM_Contact_BAO_Contact::buildOptions('gender_id'),
......@@ -349,33 +352,33 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
'alter_display' => 'alterGenderID',
'is_fields' => TRUE,
'is_filters' => TRUE,
),
'birth_date' => array(
],
'birth_date' => [
'title' => 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' => array(
],
'age' => [
'title' => ts($options['prefix_label'] . 'Age'),
'dbAlias' => 'TIMESTAMPDIFF(YEAR, ' . $tableAlias . '.birth_date, CURDATE())',
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
),
);
],
];
if (!$orgOnly) {
$spec = array_merge($spec, $individualFields);
}
if (!empty($options['custom_fields'])) {
$this->_customGroupExtended[$options['prefix'] . 'civicrm_contact'] = array(
$this->_customGroupExtended[$options['prefix'] . 'civicrm_contact'] = [
'extends' => $options['custom_fields'],
'title' => $options['prefix_label'],
'filters' => $options['filters'],
'prefix' => $options['prefix'],
'prefix_label' => $options['prefix_label'],
);
];
}
return $this->buildColumns($spec, $options['prefix'] . 'civicrm_contact', 'CRM_Contact_DAO_Contact', $tableAlias, $this->getDefaultsFromOptions($options), $options);
......@@ -389,32 +392,32 @@ trait CRM_Extendedreport_Form_Report_ColumnDefinitionTrait {
* @return array
*/
function getLatestActivityColumns($options) {
$defaultOptions = array(
$defaultOptions = [
'prefix' => '',