3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2018
35 class CRM_Report_Form_Campaign_SurveyDetails
extends CRM_Report_Form
{
37 protected $_emailField = FALSE;
39 protected $_phoneField = FALSE;
41 protected $_locationBasedPhoneField = FALSE;
43 protected $_summary = NULL;
44 protected $_customGroupGroupBy = FALSE;
45 protected $_customGroupExtends = array(
52 public $_drilldownReport = array('contact/detail' => 'Link to Detail Report');
54 private static $_surveyRespondentStatus;
56 // Survey Question titles are overridden when in print or pdf mode to
57 // say Q1, Q2 instead of the full title - to save space.
58 private $_columnTitleOverrides = array();
64 public function __construct() {
65 //filter options for survey activity status.
66 $responseStatus = array('' => '- Any -');
67 self
::$_surveyRespondentStatus = array();
68 $activityStatus = CRM_Core_PseudoConstant
::activityStatus('name');
69 if ($statusId = array_search('Scheduled', $activityStatus)) {
70 $responseStatus[$statusId] = ts('Reserved');
71 self
::$_surveyRespondentStatus[$statusId] = 'Reserved';
73 if ($statusId = array_search('Completed', $activityStatus)) {
74 $responseStatus[$statusId] = ts('Interviewed');
75 self
::$_surveyRespondentStatus[$statusId] = 'Interviewed';
78 $optionGroups = CRM_Campaign_BAO_Survey
::getResultSets('name');
79 $resultOptions = array();
80 foreach ($optionGroups as $gid => $name) {
83 $value = CRM_Core_OptionGroup
::values($name);
85 $value = array_combine($value, $value);
87 $resultOptions = $resultOptions +
$value;
90 asort($resultOptions);
92 //get all interviewers.
93 $allSurveyInterviewers = CRM_Campaign_BAO_Survey
::getInterviewers();
95 $this->_columns
= array(
96 'civicrm_activity_contact' => array(
97 'dao' => 'CRM_Activity_DAO_ActivityContact',
98 'fields' => array('contact_id' => array('title' => ts('Interviewer Name'))),
100 'contact_id' => array(
101 'name' => 'contact_id',
102 'title' => ts('Interviewer Name'),
103 'type' => CRM_Utils_Type
::T_INT
,
104 'operatorType' => CRM_Report_Form
::OP_SELECT
,
106 '' => ts('- any interviewer -'),
107 ) +
$allSurveyInterviewers,
110 'grouping' => 'survey-interviewer-fields',
112 'civicrm_contact' => array(
113 'dao' => 'CRM_Contact_DAO_Contact',
116 'title' => ts('Contact ID'),
117 'no_display' => TRUE,
120 'sort_name' => array(
121 'title' => ts('Respondent Name'),
127 'sort_name' => array(
128 'title' => ts('Respondent Name'),
129 'operator' => 'like',
132 'grouping' => 'contact-fields',
133 'order_bys' => array(
134 'sort_name' => array(
135 'title' => ts('Respondent Name'),
140 'civicrm_phone' => array(
141 'dao' => 'CRM_Core_DAO_Phone',
145 'title' => ts('Phone'),
148 'grouping' => 'location-fields',
150 'civicrm_email' => array(
151 'dao' => 'CRM_Core_DAO_Email',
155 'title' => ts('Email'),
158 'grouping' => 'location-fields',
160 ) +
$this->getAddressColumns() +
162 'civicrm_activity' => array(
163 'dao' => 'CRM_Activity_DAO_Activity',
164 'alias' => 'survey_activity',
166 'survey_id' => array(
167 'name' => 'source_record_id',
168 'title' => ts('Survey'),
169 'type' => CRM_Utils_Type
::T_INT
,
170 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
171 'options' => CRM_Campaign_BAO_Survey
::getSurveys(),
173 'survey_response' => array(
174 'name' => 'survey_response',
175 'title' => ts('Survey Responses'),
179 'title' => ts('Note'),
185 'title' => ts('Survey Result'),
187 'activity_date_time' => array(
188 'name' => 'activity_date_time',
189 'title' => ts('Date'),
190 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
194 'survey_id' => array(
195 'name' => 'source_record_id',
196 'title' => ts('Survey'),
197 'type' => CRM_Utils_Type
::T_INT
,
198 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
199 'options' => CRM_Campaign_BAO_Survey
::getSurveys(),
201 'status_id' => array(
202 'name' => 'status_id',
203 'title' => ts('Respondent Status'),
204 'type' => CRM_Utils_Type
::T_INT
,
205 'operatorType' => CRM_Report_Form
::OP_SELECT
,
206 'options' => $responseStatus,
209 'title' => ts('Survey Result'),
210 'type' => CRM_Utils_Type
::T_STRING
,
211 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
212 'options' => $resultOptions,
214 'activity_date_time' => array(
215 'title' => ts('Date'),
216 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
217 'operatorType' => CRM_Report_Form
::OP_DATE
,
220 'grouping' => 'survey-activity-fields',
221 'order_bys' => array(
222 'activity_date_time' => array(
223 'title' => ts('Date'),
228 parent
::__construct();
231 public function preProcess() {
232 parent
::preProcess();
235 public function select() {
238 //add the survey response fields.
239 $this->_addSurveyResponseColumns();
241 $this->_columnHeaders
= array();
242 foreach ($this->_columns
as $tableName => $table) {
243 if (!isset($table['fields'])) {
246 foreach ($table['fields'] as $fieldName => $field) {
247 if (!empty($field['required']) ||
248 !empty($this->_params
['fields'][$fieldName]) ||
249 CRM_Utils_Array
::value('is_required', $field)
252 $fieldsName = CRM_Utils_Array
::value(1, explode('_', $tableName));
254 $this->{"_$fieldsName" . 'Field'} = TRUE;
257 //need to pickup custom data/survey response fields.
258 if ($fieldName == 'survey_response') {
262 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
265 $title = CRM_Utils_Array
::value('title', $field);
266 // Check for an override.
267 if (!empty($this->_columnTitleOverrides
["{$tableName}_{$fieldName}"])) {
268 $title = $this->_columnTitleOverrides
["{$tableName}_{$fieldName}"];
270 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $title;
272 $this->_selectAliases
[] = "{$tableName}_{$fieldName}";
277 $this->_select
= "SELECT " . implode(",\n", $select) . " ";
280 public function from() {
281 $this->_from
= " FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom} ";
282 $activityContacts = CRM_Activity_BAO_ActivityContact
::buildOptions('record_type_id', 'validate');
283 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
284 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
286 //get the activity table joins.
287 $this->_from
.= " INNER JOIN civicrm_activity_contact civicrm_activity_target ON
288 ( {$this->_aliases['civicrm_contact']}.id = civicrm_activity_target.contact_id AND civicrm_activity_target.record_type_id = {$targetID}) \n";
289 $this->_from
.= " INNER JOIN civicrm_activity {$this->_aliases['civicrm_activity']} ON
290 ( {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id )\n";
291 $this->_from
.= " INNER JOIN civicrm_activity_contact activity_contact_civireport ON
292 ( {$this->_aliases['civicrm_activity']}.id = activity_contact_civireport.activity_id AND activity_contact_civireport.record_type_id = {$assigneeID} )\n";
294 $this->joinAddressFromContact();
295 $this->joinPhoneFromContact();
296 $this->joinEmailFromContact();
298 if ($this->_locationBasedPhoneField
) {
299 foreach ($this->_surveyResponseFields
as $key => $value) {
300 if (substr($key, 0, 5) == 'phone' && !empty($value['location_type_id'])
302 $fName = str_replace('-', '_', $key);
303 $this->_from
.= "LEFT JOIN civicrm_phone " .
304 $this->_aliases
["civicrm_phone_{$fName}"] .
305 " ON {$this->_aliases['civicrm_contact']}.id = " .
306 $this->_aliases
["civicrm_phone_{$fName}"] . ".contact_id AND " .
307 $this->_aliases
["civicrm_phone_{$fName}"] .
308 ".location_type_id = {$value['location_type_id']} AND " .
309 $this->_aliases
["civicrm_phone_{$fName}"] .
310 ".phone_type_id = {$value['phone_type_id']}\n";
316 public function where() {
318 foreach ($this->_columns
as $tableName => $table) {
319 if (array_key_exists('filters', $table)) {
320 foreach ($table['filters'] as $fieldName => $field) {
323 if (CRM_Utils_Array
::value('type', $field) & CRM_Utils_Type
::T_DATE
) {
324 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
325 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
326 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
328 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
331 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
333 $clause = $this->whereClause($field,
335 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
336 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
337 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
342 if (!empty($clause)) {
343 $clauses[] = $clause;
349 //apply survey activity types filter.
350 $surveyActivityTypes = CRM_Campaign_BAO_Survey
::getSurveyActivityType();
351 if (!empty($surveyActivityTypes)) {
352 $clauses[] = "( {$this->_aliases['civicrm_activity']}.activity_type_id IN ( " .
353 implode(' , ', array_keys($surveyActivityTypes)) . ' ) )';
356 // always filter out deleted activities (so contacts that have been released
357 // don't show up in the report).
358 $clauses[] = "( {$this->_aliases['civicrm_activity']}.is_deleted = 0 )";
360 if (empty($clauses)) {
361 $this->_where
= "WHERE ( 1 ) ";
364 $this->_where
= "WHERE " . implode(' AND ', $clauses);
367 if ($this->_aclWhere
) {
368 $this->_where
.= " AND {$this->_aclWhere} ";
372 public function compileContent() {
373 $coverSheet = $this->_surveyCoverSheet() .
374 "<div style=\"page-break-after: always\"></div>";
375 $templateFile = $this->getHookedTemplateFileName();
377 CRM_Core_Form
::$_template->fetch($templateFile) .
378 CRM_Utils_Array
::value('report_footer', $this->_formValues
);
382 * @return bool|mixed|null|string
384 private function _surveyCoverSheet() {
386 $surveyIds = CRM_Utils_Array
::value('survey_id_value', $this->_params
);
387 if (CRM_Utils_System
::isNull($surveyIds)) {
393 $surveyResponseFields = array();
394 foreach ($this->_columns
as $tableName => $values) {
395 if (!is_array($values['fields'])) {
398 foreach ($values['fields'] as $name => $field) {
399 if (!empty($field['isSurveyResponseField'])) {
400 $fldId = substr($name, 7);
401 $fieldIds[$fldId] = $fldId;
402 $title = CRM_Utils_Array
::value('label', $field, $field['title']);
403 $surveyResponseFields[$name] = array(
406 'name' => "{$tableName}_{$name}",
412 //now pickup all options.
413 if (!empty($fieldIds)) {
415 SELECT field.id as id,
418 FROM civicrm_custom_field field
419 INNER JOIN civicrm_option_value val ON ( val.option_group_id = field.option_group_id )
420 WHERE field.id IN (' . implode(' , ', $fieldIds) . ' )
421 Order By val.weight';
422 $field = CRM_Core_DAO
::executeQuery($query);
424 while ($field->fetch()) {
425 $name = "custom_{$field->id}";
426 $surveyResponseFields[$name]['options'][$field->value
] = $field->label
;
430 //get the result values.
432 SELECT survey.id as id,
433 survey.title as title,
436 FROM civicrm_survey survey
437 INNER JOIN civicrm_option_value val ON ( val.option_group_id = survey.result_id )
438 WHERE survey.id IN ( ' . implode(' , ', array_values($surveyIds)) . ' )
439 Order By val.weight';
440 $resultSet = CRM_Core_DAO
::executeQuery($query);
441 $surveyResultFields = array();
442 while ($resultSet->fetch()) {
443 $surveyResultFields[$resultSet->id
]['title'] = $resultSet->title
;
444 $surveyResultFields[$resultSet->id
]['options'][$resultSet->value
] = $resultSet->label
;
447 $this->assign('surveyResultFields', $surveyResultFields);
448 $this->assign('surveyResponseFields', $surveyResponseFields);
450 $templateFile = 'CRM/Report/Form/Campaign/SurveyCoverSheet.tpl';
451 $coverSheet = CRM_Core_Form
::$_template->fetch($templateFile);
457 * Alter display of rows.
459 * Iterate through the rows retrieved via SQL and make changes for display purposes,
460 * such as rendering contacts as links.
463 * Rows generated by SQL, with an array for each row.
465 public function alterDisplay(&$rows) {
467 $this->_formatSurveyResult($rows);
468 $this->_formatSurveyResponseData($rows);
471 foreach ($rows as $rowNum => $row) {
472 // handle state province
473 if (array_key_exists('civicrm_address_state_province_id', $row)) {
474 if ($value = $row['civicrm_address_state_province_id']) {
475 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant
::stateProvince($value);
481 if (array_key_exists('civicrm_address_country_id', $row)) {
482 if ($value = $row['civicrm_address_country_id']) {
483 $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant
::country($value);
488 // convert display name to links
489 if (array_key_exists('civicrm_contact_sort_name', $row) &&
490 array_key_exists('civicrm_contact_id', $row)
492 $url = CRM_Report_Utils_Report
::getNextUrl('contact/detail',
493 'reset=1&force=1&id_op=eq&id_value=' .
494 $row['civicrm_contact_id'],
495 $this->_absoluteUrl
, $this->_id
, $this->_drilldownReport
497 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
501 if (array_key_exists('civicrm_activity_contact_contact_id', $row)) {
502 $rows[$rowNum]['civicrm_activity_contact_contact_id'] = CRM_Utils_Array
::value($row['civicrm_activity_contact_contact_id'],
503 CRM_Campaign_BAO_Survey
::getInterviewers()
508 if (array_key_exists('civicrm_activity_survey_id', $row)) {
509 $rows[$rowNum]['civicrm_activity_survey_id'] = CRM_Utils_Array
::value($row['civicrm_activity_survey_id'],
510 CRM_Campaign_BAO_Survey
::getSurveys()
515 // skip looking further in rows, if first row itself doesn't
516 // have the column we need
526 private function _formatSurveyResult(&$rows) {
527 $surveyIds = CRM_Utils_Array
::value('survey_id_value', $this->_params
);
528 if (CRM_Utils_System
::isNull($surveyIds) ||
529 empty($this->_params
['fields']['result']) ||
530 !in_array($this->_outputMode
, array('print', 'pdf'))
535 //swap the survey result label w/ value.
537 SELECT survey.id as id,
540 FROM civicrm_option_value val
541 INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id )
542 INNER JOIN civicrm_survey survey ON ( survey.result_id = grp.id )
543 WHERE survey.id IN (' . implode(' , ', array_values($surveyIds)) . ' )
544 Order By val.weight';
546 $result = CRM_Core_DAO
::executeQuery($query);
547 $resultSet = array();
548 while ($result->fetch()) {
549 $resultSet[$result->id
][$result->value
] = $result->label
;
552 $statusId = CRM_Utils_Array
::value('status_id_value', $this->_params
);
553 $respondentStatus = CRM_Utils_Array
::value($statusId, self
::$_surveyRespondentStatus);
555 $surveyId = CRM_Utils_Array
::value(0, $surveyIds);
556 foreach ($rows as & $row) {
557 if (!empty($row['civicrm_activity_survey_id'])) {
558 $surveyId = $row['civicrm_activity_survey_id'];
560 $result = CRM_Utils_Array
::value($surveyId, $resultSet, array());
561 $resultLabel = CRM_Utils_Array
::value('civicrm_activity_result', $row);
562 if ($respondentStatus == 'Reserved') {
563 $row['civicrm_activity_result'] = implode(' | ', array_keys($result));
565 elseif ($resultLabel) {
566 $resultValue = array_search($resultLabel, $result);
568 $row['civicrm_activity_result'] = $resultValue;
577 private function _formatSurveyResponseData(&$rows) {
578 $surveyIds = CRM_Utils_Array
::value('survey_id_value', $this->_params
);
579 if (CRM_Utils_System
::isNull($surveyIds) ||
580 empty($this->_params
['fields']['survey_response'])
585 $surveyResponseFields = array();
586 $surveyResponseFieldIds = array();
587 foreach ($this->_columns
as $tableName => $values) {
588 if (!is_array($values['fields'])) {
591 foreach ($values['fields'] as $name => $field) {
592 if (!empty($field['isSurveyResponseField'])) {
593 $fldId = substr($name, 7);
594 $surveyResponseFields[$name] = "{$tableName}_{$name}";
595 $surveyResponseFieldIds[$fldId] = $fldId;
600 if (empty($surveyResponseFieldIds)) {
604 $hasResponseData = FALSE;
605 foreach ($surveyResponseFields as $fldName) {
606 foreach ($rows as $row) {
607 if (!empty($row[$fldName])) {
608 $hasResponseData = TRUE;
614 //do check respondent status.
615 $statusId = CRM_Utils_Array
::value('status_id_value', $this->_params
);
616 $respondentStatus = CRM_Utils_Array
::value($statusId, self
::$_surveyRespondentStatus);
618 if (!$hasResponseData &&
619 ($respondentStatus != 'Reserved')
624 //start response data formatting.
633 FROM civicrm_custom_field cf
634 INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id )
635 LEFT JOIN civicrm_option_value ov ON ( cf.option_group_id = ov.option_group_id )
636 WHERE cf.id IN ( ' . implode(' , ', $surveyResponseFieldIds) . ' )
639 $responseFields = array();
640 $fieldValueMap = array();
649 $responseField = CRM_Core_DAO
::executeQuery($query);
650 while ($responseField->fetch()) {
651 $reponseFldName = $responseField->table_name
. '_custom_' .
653 foreach ($properties as $prop) {
654 $responseFields[$reponseFldName][$prop] = $responseField->$prop;
656 if ($responseField->option_group_id
) {
657 //show value for print and pdf.
658 $value = $responseField->label
;
659 if (in_array($this->_outputMode
, array(
663 $value = $responseField->value
;
665 $fieldValueMap[$responseField->option_group_id
][$responseField->value
] = $value;
668 $responseField->free();
670 //actual data formatting.
672 foreach ($rows as & $row) {
673 if (!is_array($row)) {
677 foreach ($row as $name => & $value) {
678 if (!array_key_exists($name, $responseFields)) {
682 if ($respondentStatus == 'Reserved' &&
683 in_array($this->_outputMode
, array('print', 'pdf'))
685 $optGrpId = CRM_Utils_Array
::value('option_group_id', $responseFields[$name]);
686 $options = CRM_Utils_Array
::value($optGrpId, $fieldValueMap, array());
687 $value = implode(' | ', array_keys($options));
690 $value = CRM_Core_BAO_CustomField
::displayValue($value, $responseFields[$name]['id']);
700 private function _addSurveyResponseColumns() {
701 $surveyIds = CRM_Utils_Array
::value('survey_id_value', $this->_params
);
702 if (CRM_Utils_System
::isNull($surveyIds) ||
703 empty($this->_params
['fields']['survey_response'])
708 $responseFields = array();
709 foreach ($surveyIds as $surveyId) {
710 $responseFields +
= CRM_Campaign_BAO_Survey
::getSurveyResponseFields($surveyId);
711 $this->_surveyResponseFields
= $responseFields;
713 foreach ($responseFields as $key => $value) {
714 if (substr($key, 0, 5) == 'phone' && !empty($value['location_type_id'])) {
715 $fName = str_replace('-', '_', $key);
716 $this->_columns
["civicrm_{$fName}"] = array(
717 'dao' => 'CRM_Core_DAO_Phone',
718 'alias' => "phone_civireport_{$fName}",
720 $fName => array_merge($value, array(
721 'is_required' => '1',
722 'alias' => "phone_civireport_{$fName}",
723 'dbAlias' => "phone_civireport_{$fName}.phone",
724 'no_display' => TRUE,
729 $this->_aliases
["civicrm_phone_{$fName}"] = $this->_columns
["civicrm_{$fName}"]['alias'];
730 $this->_locationBasedPhoneField
= TRUE;
733 $responseFieldIds = array();
734 foreach (array_keys($responseFields) as $key) {
735 $cfId = CRM_Core_BAO_CustomField
::getKeyID($key);
737 $responseFieldIds[$cfId] = $cfId;
740 if (empty($responseFieldIds)) {
753 FROM civicrm_custom_group cg
754 INNER JOIN civicrm_custom_field cf ON ( cg.id = cf.custom_group_id )
755 WHERE cf.id IN ( ' . implode(' , ', $responseFieldIds) .
756 ' ) ORDER BY cf.weight';
757 $response = CRM_Core_DAO
::executeQuery($query);
759 while ($response->fetch()) {
760 $resTable = $response->table_name
;
761 $fieldName = "custom_{$response->cfId}";
763 //need to check does these custom data already included.
765 if (!array_key_exists($resTable, $this->_columns
)) {
766 $this->_columns
[$resTable]['dao'] = 'CRM_Contact_DAO_Contact';
767 $this->_columns
[$resTable]['extends'] = $response->extends;
769 if (empty($this->_columns
[$resTable]['alias'])) {
770 $this->_columns
[$resTable]['alias'] = "{$resTable}_survey_response";
772 if (!is_array(CRM_Utils_Array
::value('fields', $this->_columns
[$resTable]))) {
773 $this->_columns
[$resTable]['fields'] = array();
776 if (in_array($this->_outputMode
, array(
780 $this->_columnTitleOverrides
["{$resTable}_{$fieldName}"] = 'Q' . $fieldCnt;
784 if (array_key_exists($fieldName, $this->_columns
[$resTable]['fields'])) {
785 $this->_columns
[$resTable]['fields'][$fieldName]['required'] = TRUE;
786 $this->_columns
[$resTable]['fields'][$fieldName]['isSurveyResponseField'] = TRUE;
790 $title = $responseFields[$fieldName]['title'];
791 $fldType = 'CRM_Utils_Type::T_STRING';
792 if ($response->time_format
) {
793 $fldType = CRM_Utils_Type
::T_TIMESTAMP
;
796 'name' => $response->column_name
,
799 'label' => $responseFields[$fieldName]['title'],
800 'dataType' => $response->data_type
,
801 'htmlType' => $response->html_type
,
803 'alias' => ($response->data_type
== 'ContactReference') ?
$this->_columns
[$resTable]['alias'] .
804 '_contact' : $this->_columns
[$resTable]['alias'],
805 'dbAlias' => $this->_columns
[$resTable]['alias'] . '.' .
806 $response->column_name
,
807 'no_display' => TRUE,
808 'isSurveyResponseField' => TRUE,
811 $this->_columns
[$resTable]['fields'][$fieldName] = $field;
812 $this->_aliases
[$resTable] = $this->_columns
[$resTable]['alias'];