<?php
-// $Id$
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
require_once str_replace('_', DIRECTORY_SEPARATOR, $table['bao'] . '.php');
eval("\$expFields = {$table['bao']}::exportableFields( );");
}
- else {
+ elseif (array_key_exists('dao', $table)){
require_once str_replace('_', DIRECTORY_SEPARATOR, $table['dao'] . '.php');
eval("\$expFields = {$table['dao']}::export( );");
}
+ else{
+ $expFields = array();
+ }
$doNotCopy = array('required');
foreach ($table['filters'] as $fieldName => $field) {
if (isset($field['default'])) {
if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
- $this->_defaults["{$fieldName}_relative"] = $field['default'];
+ if(is_array($field['default'])){
+ $this->_defaults["{$fieldName}_from"] = CRM_Utils_Array::value('from', $field['default']);
+ $this->_defaults["{$fieldName}_to"] = CRM_Utils_Array::value('to', $field['default']);
+ $this->_defaults["{$fieldName}_relative"] = 0;
+ }
+ else{
+ $this->_defaults["{$fieldName}_relative"] = $field['default'];
+ }
}
else {
$this->_defaults["{$fieldName}_value"] = $field['default'];
case CRM_Report_FORM::OP_DATE:
// build datetime fields
- CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count);
+ CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count, '_from','_to', 'From:', FALSE, $operations);
$count++;
break;
case CRM_Report_FORM::OP_DATETIME:
// build datetime fields
- CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count, '_from', '_to', 'From:', FALSE, TRUE, 'searchDate', true);
+ CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count, '_from', '_to', 'From:', FALSE, $operations, 'searchDate', true);
$count++;
break;
function getOperationPair($type = "string", $fieldName = NULL) {
// FIXME: At some point we should move these key-val pairs
// to option_group and option_value table.
-
switch ($type) {
case CRM_Report_FORM::OP_INT:
case CRM_Report_FORM::OP_FLOAT:
- return array('lte' => ts('Is less than or equal to'),
+ return array(
+ 'lte' => ts('Is less than or equal to'),
'gte' => ts('Is greater than or equal to'),
'bw' => ts('Is between'),
'eq' => ts('Is equal to'),
break;
case CRM_Report_FORM::OP_SELECT:
- return array('eq' => ts('Is equal to'));
+ return array(
+ 'eq' => ts('Is equal to'),
+ );
case CRM_Report_FORM::OP_MONTH:
case CRM_Report_FORM::OP_MULTISELECT:
- return array('in' => ts('Is one of'),
+ return array(
+ 'in' => ts('Is one of'),
'notin' => ts('Is not one of'),
);
break;
case CRM_Report_FORM::OP_DATE:
- return array('nll' => ts('Is empty (Null)'),
+ return array(
+ 'nll' => ts('Is empty (Null)'),
'nnll' => ts('Is not empty (Null)'),
);
break;
case CRM_Report_FORM::OP_MULTISELECT_SEPARATOR:
// use this operator for the values, concatenated with separator. For e.g if
// multiple options for a column is stored as ^A{val1}^A{val2}^A
- return array('mhas' => ts('Is one of'));
+ return array(
+ 'mhas' => ts('Is one of'),
+ );
default:
// type is string
- return array('has' => ts('Contains'),
+ return array(
+ 'has' => ts('Contains'),
'sw' => ts('Starts with'),
'ew' => ts('Ends with'),
'nhas' => ts('Does not contain'),
}
if (!array_key_exists('type', $curFields[$fieldName])) {
- $curFields[$fieldName]['type'] = $curFilters[$fieldName]['type'];
+ $curFields[$fieldName]['type'] = CRM_Utils_Array::value('type', $curFilters[$fieldName], array());
}
if ($addFields) {
foreach (array(
'value', 'min', 'max', 'relative', 'from', 'to') as $attach) {
if (isset($this->_params[$fieldAlias . '_' . $attach]) &&
- (!empty($this->_params[$fieldAlias . '_' . $attach]) || $this->_params[$fieldAlias . '_' . $attach] == '0')
- ) {
+ (!empty($this->_params[$fieldAlias . '_' . $attach])
+ || ($attach != 'relative' && $this->_params[$fieldAlias . '_' . $attach] == '0')
+ )
+ ){
return TRUE;
}
}
return $this->_selectedTables;
}
- /*
+ /**
+ * @deprecated - use getAddressColumns which is a more accurate description
+ * and also accepts an array of options rather than a long list
+ *
* function for adding address fields to construct function in reports
* @param bool $groupBy Add GroupBy? Not appropriate for detail report
* @param bool $orderBy Add GroupBy? Not appropriate for detail report
}
}
+ /**
+ * Add Phone into From Table if required
+ */
+ function addPhoneFromClause() {
+ // include address field if address column is to be included
+ if ($this->isTableSelected('civicrm_phone')
+ ) {
+ $this->_from .= "
+ LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
+ ON ({$this->_aliases['civicrm_contact']}.id =
+ {$this->_aliases['civicrm_phone']}.contact_id) AND
+ {$this->_aliases['civicrm_phone']}.is_primary = 1\n";
+ }
+ }
+
+ /**
+ * Get phone columns to add to array
+ * @param array $options
+ * - prefix Prefix to add to table (in case of more than one instance of the table)
+ * - prefix_label Label to give columns from this phone table instance
+ * @return array phone columns definition
+ */
+ function getPhoneColumns($options = array()){
+ $defaultOptions = array(
+ 'prefix' => '',
+ 'prefix_label' => '',
+ );
+
+ $options = array_merge($defaultOptions,$options);
+
+ $fields = array(
+ $options['prefix'] . 'civicrm_phone' => array(
+ 'dao' => 'CRM_Core_DAO_Phone',
+ 'fields' => array(
+ $options['prefix'] . 'phone' => array(
+ 'title' => ts($options['prefix_label'] . 'Phone'),
+ 'name' => 'phone'
+ ),
+ ),
+ ),
+ );
+ return $fields;
+ }
+
+ /**
+ * Get address columns to add to array
+ * @param array $options
+ * - prefix Prefix to add to table (in case of more than one instance of the table)
+ * - prefix_label Label to give columns from this address table instance
+ * @return array address columns definition
+ */
+ function getAddressColumns($options = array()){
+ $defaultOptions = array(
+ 'prefix' => '',
+ 'prefix_label' => '',
+ 'group_by' => TRUE,
+ 'order_by' => TRUE,
+ 'filters' => TRUE,
+ 'defaults' => array(
+ ),
+ );
+ $options = array_merge($defaultOptions,$options);
+ return $this->addAddressFields(
+ $options['group_by'],
+ $options['order_by'],
+ $options['filters'],
+ $options['defaults']
+ );
+
+ }
+
function add2group($groupID) {
if (is_numeric($groupID) && isset($this->_aliases['civicrm_contact'])) {
$select = "SELECT DISTINCT {$this->_aliases['civicrm_contact']}.id AS addtogroup_contact_id, ";