From: Deepak Srivastava Date: Mon, 26 Aug 2013 14:03:16 +0000 (+0530) Subject: CRM-13263 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c75e90fab9ca10852886deb5d0ad5b608f8fb8aa;p=civicrm-core.git CRM-13263 --- diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index d15845937a..b2f39dae31 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -437,14 +437,15 @@ class CRM_Report_Form extends CRM_Core_Form { $this->_aliases[$tableName] = $this->_columns[$tableName]['alias']; + $daoOrBaoName = NULL; // higher preference to bao object if (array_key_exists('bao', $table)) { - $baoName = $table['bao']; - $expFields = $baoName::exportableFields( ); + $daoOrBaoName = $table['bao']; + $expFields = $daoOrBaoName::exportableFields( ); } elseif (array_key_exists('dao', $table)){ - $daoName = $table['dao']; - $expFields = $daoName::export( ); + $daoOrBaoName = $table['dao']; + $expFields = $daoOrBaoName::export( ); } else{ $expFields = array(); @@ -506,18 +507,42 @@ class CRM_Report_Form extends CRM_Core_Form { $this->_columns[$tableName][$fieldGrp][$fieldName]['dbAlias'] = $alias . '.' . $this->_columns[$tableName][$fieldGrp][$fieldName]['name']; } - if (CRM_Utils_Array::value('type', $this->_columns[$tableName][$fieldGrp][$fieldName]) && - !isset($this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType']) - ) { - if (in_array($this->_columns[$tableName][$fieldGrp][$fieldName]['type'], - array(CRM_Utils_Type::T_MONEY, CRM_Utils_Type::T_FLOAT) - )) { - $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_FLOAT; - } - elseif (in_array($this->_columns[$tableName][$fieldGrp][$fieldName]['type'], - array(CRM_Utils_Type::T_INT) - )) { - $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_INT; + // a few auto fills for filters + if ($fieldGrp == 'filters') { + // fill operator types + if (!array_key_exists('operatorType', $this->_columns[$tableName][$fieldGrp][$fieldName])) { + switch (CRM_Utils_Array::value('type', $this->_columns[$tableName][$fieldGrp][$fieldName])) { + case CRM_Utils_Type::T_MONEY: + case CRM_Utils_Type::T_FLOAT: + $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_FLOAT; + break; + case CRM_Utils_Type::T_INT: + $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_INT; + break; + case CRM_Utils_Type::T_DATE: + $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_DATE; + break; + case CRM_Utils_Type::T_BOOLEAN: + $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT; + if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) { + $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] = + array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes')); + } + break; + default: + if ($daoOrBaoName && + (array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName]) + || array_key_exists('enumValues', $this->_columns[$tableName][$fieldGrp][$fieldName])) + ) { + // with multiple options operator-type is generally multi-select + $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT; + if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) { + // fill options + $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] = CRM_Core_PseudoConstant::get($daoOrBaoName, $fieldName); + } + } + break; + } } } }