*/
protected $sql;
+
+ /**
+ * SQL being run in this report as an array.
+ *
+ * The sql in the report is stored in this variable in order to be returned to api & test calls.
+ *
+ * @var string
+ */
+
+ protected $sqlArray;
/**
* Class constructor.
*/
);
$this->assignTabs();
+ $this->sqlArray[] = $sql;
foreach (array('LEFT JOIN') as $term) {
$sql = str_replace($term, '<br>  ' . $term, $sql);
}
}
if (!empty($orderByField)) {
- $this->_orderByFields[] = $orderByField;
+ $this->_orderByFields[$orderByField['tplField']] = $orderByField;
$orderBys[] = "{$orderByField['dbAlias']} {$orderBy['order']}";
// Record any section headers for assignment to the template
* @return array
*/
public function unselectedSectionColumns() {
- $selectColumns = array();
- foreach ($this->_columns as $tableName => $table) {
- if (array_key_exists('fields', $table)) {
- foreach ($table['fields'] as $fieldName => $field) {
- if (!empty($field['required']) ||
- !empty($this->_params['fields'][$fieldName])
- ) {
-
- $selectColumns["{$tableName}_{$fieldName}"] = 1;
- }
- }
- }
- }
-
if (is_array($this->_sections)) {
- return array_diff_key($this->_sections, $selectColumns);
+ return array_diff_key($this->_sections, $this->getSelectColumns());
}
else {
return array();
return $this->_resultSet;
}
+ /**
+ * Get the sql used to generate the report.
+ *
+ * @return string
+ */
+ public function getReportSql() {
+ return $this->sqlArray;
+ }
+
/**
* Use the form name to create the tpl file name.
*
return;
}
$mapper = CRM_Core_BAO_CustomQuery::$extendsMap;
+ $customTables = explode(',', CRM_Core_DAO::singleValueQuery("SELECT GROUP_CONCAT(table_name) FROM civicrm_custom_group"));
foreach ($this->_columns as $table => $prop) {
- if (substr($table, 0, 13) == 'civicrm_value' ||
- substr($table, 0, 12) == 'custom_value'
- ) {
+ if (in_array($table, $customTables)) {
$extendsTable = $mapper[$prop['extends']];
// check field is in params
$this->assign('sections', $this->_sections);
}
+ /**
+ * Get an array of the columns that have been selected for display.
+ *
+ * @return array
+ */
+ public function getSelectColumns() {
+ $selectColumns = array();
+ foreach ($this->_columns as $tableName => $table) {
+ if (array_key_exists('fields', $table)) {
+ foreach ($table['fields'] as $fieldName => $field) {
+ if (!empty($field['required']) ||
+ !empty($this->_params['fields'][$fieldName])
+ ) {
+
+ $selectColumns["{$tableName}_{$fieldName}"] = 1;
+ }
+ }
+ }
+ }
+ return $selectColumns;
+ }
+
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
/**
);
public $_drilldownReport = array('contact/detail' => 'Link to Detail Report');
+ /**
+ * This will be a_b or b_a.
+ *
+ * @var string
+ */
+ protected $relationType;
+
/**
* Class constructor.
*/
public function postProcess() {
$this->beginPostProcess();
- $this->relationType = NULL;
$originalRelationshipTypeIdValue = $this->_params['relationship_type_id_value'];
if (!empty($this->_params['relationship_type_id_value'])) {
$relationshipTypes = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form {
/**
*/
public function __construct() {
+ $this->_rollup = 'WITH ROLLUP';
$this->_autoIncludeIndexedFieldsAsOrderBys = 1;
$yearsInPast = 10;
$yearsInFuture = 1;
'operatorType' => CRM_Report_Form::OP_SELECT,
'options' => $optionYear,
'default' => date('Y'),
+ 'type' => CRM_Utils_Type::T_INT,
),
'financial_type_id' => array(
'title' => ts('Financial Type'),
parent::__construct();
}
- public function preProcess() {
- parent::preProcess();
- }
-
public function select() {
$this->_columnHeaders = $select = array();
public function groupBy() {
$this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, " .
self::fiscalYearOffset($this->_aliases['civicrm_contribution'] .
- '.receive_date') . " WITH ROLLUP";
+ '.receive_date') . " " . $this->_rollup;
$this->assign('chartSupported', TRUE);
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form {
/**
*/
public function __construct() {
+ $this->_rollup = 'WITH ROLLUP';
$this->_autoIncludeIndexedFieldsAsOrderBys = 1;
$yearsInPast = 10;
$yearsInFuture = 1;
'operatorType' => CRM_Report_Form::OP_SELECT,
'options' => $optionYear,
'default' => date('Y'),
+ 'type' => CRM_Utils_Type::T_INT,
),
'financial_type_id' => array(
'title' => ts('Financial Type'),
$this->assign('chartSupported', TRUE);
$this->_groupBy = "Group BY {$this->_aliases['civicrm_contribution']}.contact_id, " .
self::fiscalYearOffset($this->_aliases['civicrm_contribution'] .
- '.receive_date') . " WITH ROLLUP ";
+ '.receive_date') . " " . " " . $this->_rollup;
}
/**
'state_province_id' => array(
'title' => ts('State/Province'),
'default' => TRUE,
+ 'type' => CRM_Utils_Type::T_INT,
),
'country_id' => array(
'title' => ts('Country'),
$sql = $reportInstance->buildQuery();
$rows = $metadata = $requiredMetadata = array();
$reportInstance->buildRows($sql, $rows);
- $requiredMetadata = array();
+ $reportInstance->formatDisplay($rows);
+
if (isset($params['options']) && !empty($params['options']['metadata'])) {
$requiredMetadata = $params['options']['metadata'];
if (in_array('title', $requiredMetadata)) {
}
if (in_array('labels', $requiredMetadata)) {
foreach ($reportInstance->_columnHeaders as $key => $header) {
- //would be better just to expect reports to provide titles but reports are not consistent so we anticipate empty
+ // Would be better just to expect reports to provide titles but reports are not consistent so we anticipate empty
//NB I think these are already translated
$metadata['metadata']['labels'][$key] = !empty($header['title']) ? $header['title'] : '';
}
}
+ if (in_array('sql', $requiredMetadata)) {
+ $metadata['metadata']['sql'] = $reportInstance->getReportSql();
+ }
}
return array($rows, $reportInstance, $metadata);
}
public static function getReportTemplates() {
$reportsToSkip = array(
'activity' => 'does not respect function signature on from clause',
- 'walklist' => 'Notice: Undefined index: type in CRM_Report_Form_Walklist_Walklist line 155.(suspect the select function should be removed in favour of the parent (state province field) also, type should be added to state province & others? & potentially getAddressColumns fn should be used per other reports',
'contribute/repeat' => 'Reports with important functionality in postProcess are not callable via the api. For variable setting recommend beginPostProcessCommon, for temp table creation recommend From fn',
'contribute/topDonor' => 'construction of query in postProcess makes inaccessible ',
- 'contribute/sybunt' => 'e notice - (ui gives fatal error at civicrm/report/contribute/sybunt&reset=1&force=1 e-notice is on yid_valueContribute/Sybunt.php(214) because at the force url "yid_relative" not "yid_value" is defined',
- 'contribute/lybunt' => 'same as sybunt - fatals on force url & test identifies why',
'event/income' => 'I do no understand why but error is Call to undefined method CRM_Report_Form_Event_Income::from() in CRM/Report/Form.php on line 2120',
- 'contact/relationship' => '(see contribute/repeat), property declaration issue, Undefined property: CRM_Report_Form_Contact_Relationship::$relationType in /Contact/Relationship.php(486):',
'logging/contact/summary' => '(likely to be test related) probably logging off Undefined index: Form/Contact/LoggingSummary.php(231): PHP',
'logging/contact/detail' => '(likely to be test related) probably logging off DB Error: no such table',
'logging/contribute/summary' => '(likely to be test related) probably logging off DB Error: no such table',
'logging/contribute/detail' => '(likely to be test related) probably logging off DB Error: no such table',
- 'survey/detail' => '(likely to be test related) Undefined index: CiviCampaign civicrm CRM/Core/Component.php(196)',
'contribute/history' => 'Declaration of CRM_Report_Form_Contribute_History::buildRows() should be compatible with CRM_Report_Form::buildRows($sql, &$rows)',
'activitySummary' => 'We use temp tables for the main query generation and name are dynamic. These names are not available in stats() when called directly.',
);