$relative = $this->_params["{$fieldName}_relative"] ?? NULL;
$from = $this->_params["{$fieldName}_from"] ?? NULL;
$to = $this->_params["{$fieldName}_to"] ?? NULL;
- return $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']);
+ $fromTime = $this->_params["{$fieldName}_from_time"] ?? NULL;
+ $toTime = $this->_params["{$fieldName}_to_time"] ?? NULL;
+ return $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
}
}
else {
'type' => CRM_Utils_Type::T_INT,
],
'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATETIME],
+ 'receipt_date' => ['operatorType' => CRM_Report_Form::OP_DATETIME],
'contribution_source' => [
'title' => ts('Source'),
'name' => 'source',
}
}
- public function where() {
- foreach ($this->_columns as $tableName => $table) {
- if (array_key_exists('filters', $table)) {
- foreach ($table['filters'] as $fieldName => $field) {
- $clause = NULL;
- if (in_array($fieldName, [
- 'credit_accounting_code',
- 'credit_name',
- 'credit_contact_id',
- ])) {
- $field['dbAlias'] = "CASE
+ /**
+ * overriding to modify dbAlias for few fields.
+ *
+ * @param array $field Field specifications
+ * @param string $op Query operator (not an exact match to sql)
+ * @param mixed $value
+ * @param float $min
+ * @param float $max
+ *
+ * @return null|string
+ */
+ public function whereClause(&$field, $op, $value, $min, $max) {
+ if ($field['alias'] == 'financial_account_civireport_credit' &&
+ in_array($field['name'], ['accounting_code', 'id', 'contact_id'])
+ ) {
+ $field['dbAlias'] = "CASE
WHEN financial_trxn_civireport.from_financial_account_id IS NOT NULL
THEN financial_account_civireport_credit_1.{$field['name']}
ELSE financial_account_civireport_credit_2.{$field['name']}
END";
- }
- if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
- $relative = $this->_params["{$fieldName}_relative"] ?? NULL;
- $from = $this->_params["{$fieldName}_from"] ?? NULL;
- $to = $this->_params["{$fieldName}_to"] ?? NULL;
- $fromTime = $this->_params["{$fieldName}_from_time"] ?? NULL;
- $toTime = $this->_params["{$fieldName}_to_time"] ?? NULL;
-
- $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
- }
- else {
- $op = $this->_params["{$fieldName}_op"] ?? NULL;
- if ($op) {
- $clause = $this->whereClause($field,
- $op,
- CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
- );
- }
- }
- if (!empty($clause)) {
- $clauses[] = $clause;
- }
- }
- }
- }
- if (empty($clauses)) {
- $this->_where = 'WHERE ( 1 )';
- }
- else {
- $this->_where = 'WHERE ' . implode(' AND ', $clauses);
}
+
+ $clause = parent::whereClause($field, $op, $value, $min, $max);
+
+ return $clause;
}
public function postProcess() {