From 56ecdf7ba196caef3b58117e87f058cae97f5604 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 25 Feb 2014 16:19:45 -0500 Subject: [PATCH] CRM-13966 - Migrate campaign form autocompletes --- CRM/Campaign/BAO/Query.php | 24 +++--------------- CRM/Campaign/Form/Gotv.php | 5 ---- CRM/Campaign/Form/Search.php | 15 +---------- templates/CRM/Campaign/Form/Search.tpl | 25 ------------------- templates/CRM/Campaign/Form/Search/Common.tpl | 21 ++-------------- 5 files changed, 6 insertions(+), 84 deletions(-) diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php index fbc2d325e7..0b83b73566 100755 --- a/CRM/Campaign/BAO/Query.php +++ b/CRM/Campaign/BAO/Query.php @@ -194,13 +194,7 @@ class CRM_Campaign_BAO_Query { return; case 'survey_interviewer_id': - $surveyInterviewerName = NULL; - foreach ($query->_params as $paramValues) { - if (CRM_Utils_Array::value(0, $paramValues) == 'survey_interviewer_name') { - $surveyInterviewerName = CRM_Utils_Array::value(2, $paramValues); - break; - } - } + $surveyInterviewerName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'sort_name'); $query->_qill[$grouping][] = ts('Survey Interviewer - %1', array(1 => $surveyInterviewerName)); $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity_assignment.contact_id', $op, $value, 'Integer' @@ -311,6 +305,7 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) "; * * @access public * + * @param CRM_Core_Form $form * @return void * @static */ @@ -347,15 +342,8 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) "; if ($showInterviewer || $className == 'CRM_Campaign_Form_Gotv' ) { - //autocomplete url - $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', - 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1', - FALSE, NULL, FALSE - ); - $form->assign('dataUrl', $dataUrl); - $form->add('text', 'survey_interviewer_name', ts('Interviewer')); - $form->add('hidden', 'survey_interviewer_id', '', array('id' => 'survey_interviewer_id')); + $form->addEntityRef('survey_interviewer_id', ts('Interviewer'), array('class' => 'big')); $userId = NULL; if (isset($form->_interviewerId) && $form->_interviewerId) { @@ -368,11 +356,6 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) "; if ($userId) { $defaults = array(); $defaults['survey_interviewer_id'] = $userId; - $defaults['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', - $userId, - 'sort_name', - 'id' - ); $form->setDefaults($defaults); } } @@ -440,7 +423,6 @@ INNER JOIN civicrm_custom_group grp on fld.custom_group_id = grp.id return $voterClause; } $surveyId = CRM_Utils_Array::value('campaign_survey_id', $params); - $interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $params); $searchVoterFor = CRM_Utils_Array::value('campaign_search_voter_for', $params); //get the survey activities. diff --git a/CRM/Campaign/Form/Gotv.php b/CRM/Campaign/Form/Gotv.php index e6427f2b85..8a389b3952 100755 --- a/CRM/Campaign/Form/Gotv.php +++ b/CRM/Campaign/Form/Gotv.php @@ -138,11 +138,6 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form { ); $defaults['survey_interviewer_id'] = $cid; - $defaults['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', - $cid, - 'sort_name', - 'id' - ); } if ($this->_surveyId) { $defaults['campaign_survey_id'] = $this->_surveyId; diff --git a/CRM/Campaign/Form/Search.php b/CRM/Campaign/Form/Search.php index af40d5b1fb..6388660a4b 100755 --- a/CRM/Campaign/Form/Search.php +++ b/CRM/Campaign/Form/Search.php @@ -419,18 +419,10 @@ class CRM_Campaign_Form_Search extends CRM_Core_Form { $interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->_formValues); if ($interviewerId) { $this->set('interviewerId', $interviewerId); - if (empty($this->_formValues['survey_interviewer_name'])) { - $this->_formValues['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', - $interviewerId, - 'sort_name', - 'id' - ); - } } //format multi-select group and contact types. - foreach (array( - 'group', 'contact_type') as $param) { + foreach (array('group', 'contact_type') as $param) { if ($this->_force) { continue; } @@ -528,11 +520,6 @@ class CRM_Campaign_Form_Search extends CRM_Core_Form { CRM_Utils_System::civiExit(); } $this->_formValues['survey_interviewer_id'] = $cid; - $this->_formValues['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', - $cid, - 'sort_name', - 'id' - ); //get all in defaults. $this->_defaults = $this->_formValues; $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this); diff --git a/templates/CRM/Campaign/Form/Search.tpl b/templates/CRM/Campaign/Form/Search.tpl index 86b4867f06..3ced38a31b 100755 --- a/templates/CRM/Campaign/Form/Search.tpl +++ b/templates/CRM/Campaign/Form/Search.tpl @@ -53,28 +53,3 @@ {/if} {/if} -{literal} - -{/literal} diff --git a/templates/CRM/Campaign/Form/Search/Common.tpl b/templates/CRM/Campaign/Form/Search/Common.tpl index 159df5e2e7..0a5cdb992b 100755 --- a/templates/CRM/Campaign/Form/Search/Common.tpl +++ b/templates/CRM/Campaign/Form/Search/Common.tpl @@ -49,10 +49,10 @@ {if $showInterviewer} - {$form.survey_interviewer_name.label} + {$form.survey_interviewer_id.label} - {$form.survey_interviewer_name.html} + {$form.survey_interviewer_id.html} {/if} @@ -166,23 +166,6 @@ {literal} }); -//load interviewer autocomplete. -var interviewerDataUrl = "{/literal}{$dataUrl}{literal}"; -var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing contact.{/ts}{literal}"; -cj( "#survey_interviewer_name" ).autocomplete( interviewerDataUrl, - { width : 256, - selectFirst : false, - hintText: hintText, - matchContains: true, - minChars: 1 - } -).result( function( event, data, formatted ) { - cj( "#survey_interviewer_id" ).val( data[1] ); - }).bind( 'click', function( ) { - cj( "#survey_interviewer_id" ).val(''); - }); - - function buildCampaignGroups( surveyId ) { if ( !surveyId ) surveyId = cj("#campaign_survey_id").val( ); -- 2.25.1