if (!CRM_Core_Permission::check('view report sql')) {
return;
}
+ $ignored_output_modes = array('pdf', 'csv', 'print');
+ if (in_array($this->_outputMode, $ignored_output_modes)) {
+ return;
+ }
$this->tabs['Developer'] = array(
'title' => ts('Developer'),
'tpl' => 'Developer',
$this->sqlArray[] = $sql;
foreach ($this->sqlArray as $sql) {
foreach (array('LEFT JOIN') as $term) {
- $sql = str_replace($term, '<br>  ' . $term, $sql);
+ $sql = str_replace($term, '<br> ' . $term, $sql);
}
foreach (array('FROM', 'WHERE', 'GROUP BY', 'ORDER BY', 'LIMIT', ';') as $term) {
$sql = str_replace($term, '<br><br>' . $term, $sql);
$this->sqlFormattedArray[] = $sql;
$this->assign('sql', implode(';<br><br><br><br>', $this->sqlFormattedArray));
}
+ $this->assign('sqlModes', $sqlModes = CRM_Utils_SQL::getSqlModes());
+
}
/**
* @return mixed
*/
protected function alterLocationTypeID($value, &$row, $selectedfield, $criteriaFieldName) {
- $values = $this->getLocationTypeOptions();
- return CRM_Utils_Array::value($value, $values);
+ return CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Address', 'location_type_id', $value);
}
/**
if (!empty($field['pseudofield'])) {
continue;
}
- $clause = NULL;
- if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
- if (CRM_Utils_Array::value('operatorType', $field) ==
- CRM_Report_Form::OP_MONTH
- ) {
- $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
- $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params);
- if (is_array($value) && !empty($value)) {
- $clause
- = "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
- '))';
- }
- }
- else {
- $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
- $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
- $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
- $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params);
- $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params);
- $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
- }
- }
- else {
- $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
- 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)
- );
- }
- }
+ $clause = $this->generateFilterClause($field, $fieldName);
if (!empty($clause)) {
if (!empty($field['having'])) {
$entryFound = TRUE;
}
}
+
+ // Handle employer id
+ if (array_key_exists('civicrm_contact_employer_id', $row)) {
+ $employerId = $row['civicrm_contact_employer_id'];
+ if ($employerId) {
+ $rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($employerId);
+ $rows[$rowNum]['civicrm_contact_employer_id_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $employerId, $this->_absoluteUrl);
+ $rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for Employer.');
+ $entryFound = TRUE;
+ }
+ }
+
return $entryFound;
}
'is_opt_out' => array(),
'is_deceased' => array(),
'preferred_language' => array(),
+ 'employer_id' => array(
+ 'title' => ts('Current Employer'),
+ ),
);
}
* @param array $field
* @param string $table
*/
- private function setEntityRefDefaults(&$field, $table) {
+ public function setEntityRefDefaults(&$field, $table) {
$field['attributes'] = $field['attributes'] ? $field['attributes'] : array();
$field['attributes'] += array(
'entity' => CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($table)),
'is_filters' => TRUE,
'is_fields' => TRUE,
),
- $options['prefix'] . 'street_name' => array(
- 'name' => 'street_name',
- 'title' => ts($options['prefix_label'] . 'Street Name'),
- 'type' => 1,
- 'is_fields' => TRUE,
- ),
$options['prefix'] . 'street_unit' => array(
'name' => 'street_unit',
'title' => ts($options['prefix_label'] . 'Street Unit'),
}
}
+ /**
+ * Generate clause for the selected filter.
+ *
+ * @param array $field
+ * Field specification
+ * @param string $fieldName
+ * Field name.
+ *
+ * @return string
+ * Relevant where clause.
+ */
+ protected function generateFilterClause($field, $fieldName) {
+ if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
+ if (CRM_Utils_Array::value('operatorType', $field) ==
+ CRM_Report_Form::OP_MONTH
+ ) {
+ $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
+ $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params);
+ if (is_array($value) && !empty($value)) {
+ return "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
+ '))';
+ }
+ }
+ else {
+ $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
+ $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
+ $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
+ $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params);
+ $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params);
+ return $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
+ }
+ }
+ else {
+ $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
+ if ($op) {
+ return $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)
+ );
+ }
+ }
+ return '';
+ }
+
}