+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
* Variable to store redirect path
- *
*/
private $_userContext;
private $_allowAjaxReleaseButton;
/**
- * Build all the data structures needed to build the form
+ * Build all the data structures needed to build the form.
*
* @return void
*/
if ($this->_reserveToInterview || $this->_votingTab) {
//user came from voting tab / reserve form.
foreach (array(
- 'surveyId', 'contactIds', 'interviewerId') as $fld) {
+ 'surveyId',
+ 'contactIds',
+ 'interviewerId',
+ ) as $fld) {
$this->{"_$fld"} = $this->get($fld);
}
//get the target voter ids.
$this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
}
- if ( $this->_surveyId ) {
+ if ($this->_surveyId) {
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
}
- $orderClause = false;
- $buttonName = $this->controller->getButtonName();
- if ( $buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
+ $orderClause = FALSE;
+ $buttonName = $this->controller->getButtonName();
+ if ($buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
$orderByParams = CRM_Utils_Array::value('order_bys', $_POST);
}
- elseif ( CRM_Core_OptionGroup::getValue('activity_type','WalkList') == $this->_surveyDetails['activity_type_id'] ) {
- $orderByParams =
- array(
+ elseif (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
+ $orderByParams
+ = array(
1 => array(
'column' => 'civicrm_address.street_name',
- 'order' => 'ASC',
+ 'order' => 'ASC',
),
2 => array(
'column' => 'civicrm_address.street_number%2',
}
$orderBy = array();
- if ( !empty($orderByParams) ) {
- foreach ( $orderByParams as $key => $val ) {
+ if (!empty($orderByParams)) {
+ foreach ($orderByParams as $key => $val) {
if (!empty($val['column'])) {
$orderBy[] = "{$val['column']} {$val['order']}";
}
}
- if ( !empty($orderBy) ) {
+ if (!empty($orderBy)) {
$orderClause = "ORDER BY " . implode(', ', $orderBy);
}
}
$this->_contactIds = array_unique($this->_contactIds);
if (!empty($this->_contactIds) && $orderClause) {
$clause = 'contact_a.id IN ( ' . implode(',', $this->_contactIds) . ' ) ';
- $sql = "
+ $sql = "
SELECT contact_a.id
FROM civicrm_contact contact_a
LEFT JOIN civicrm_address ON contact_a.id = civicrm_address.contact_id
}
}
-
//get the contact read only fields to display.
$readOnlyFields = array_merge(array(
'contact_type' => '',
$activityIds = array();
foreach ($this->_contactIds as $key => $voterId) {
- $actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
- $statusId = CRM_Utils_Array::value('status_id', $actVals);
+ $actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
+ $statusId = CRM_Utils_Array::value('status_id', $actVals);
$activityId = CRM_Utils_Array::value('activity_id', $actVals);
if ($activityId &&
$statusId &&
$this->assign('surveyValues', $this->_surveyValues);
$result = CRM_Campaign_BAO_Survey::getReportID($this->_surveyId);
- $this->assign("instanceId",$result);
+ $this->assign("instanceId", $result);
//get the survey result options.
$this->_resultOptions = $this->get('resultOptions');
}
public function validateIds() {
- $required = array('surveyId' => ts('Could not find Survey.'),
+ $required = array(
+ 'surveyId' => ts('Could not find Survey.'),
'interviewerId' => ts('Could not find Interviewer.'),
'contactIds' => ts('No respondents are currently reserved for you to interview.'),
'resultOptions' => ts('Oops. It looks like there is no response option configured.'),
}
/**
- * Build the form object
+ * Build the form object.
*
*
* @return void
public function buildQuickForm() {
$this->assign('surveyTypeId', $this->_surveyTypeId);
- $options =
- array('' => ' - none - ',
- 'civicrm_address.street_name' => 'Street Name',
+ $options
+ = array(
+ '' => ' - none - ',
+ 'civicrm_address.street_name' => 'Street Name',
'civicrm_address.street_number%2' => 'Odd / Even Street Number',
- 'civicrm_address.street_number' => 'Street Number',
- 'contact_a.sort_name' => 'Respondent Name',
+ 'civicrm_address.street_number' => 'Street Number',
+ 'contact_a.sort_name' => 'Respondent Name',
);
for ($i = 1; $i < count($options); $i++) {
$this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options);
- $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array('ASC' => 'Ascending', 'DESC' => 'Descending'));
+ $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array(
+ 'ASC' => 'Ascending',
+ 'DESC' => 'Descending',
+ ));
}
//pickup the uf fields.
foreach ($this->_contactIds as $contactId) {
//build the profile fields.
foreach ($this->_surveyFields as $name => $field) {
- if ($field){
+ if ($field) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contactId);
}
}
if (!empty($this->_resultOptions)) {
$this->add('select', "field[$contactId][result]", ts('Result'),
array(
- '' => ts('- select -')) +
- array_combine($this->_resultOptions, $this->_resultOptions)
+ '' => ts('- select -'),
+ ) +
+ array_combine($this->_resultOptions, $this->_resultOptions)
);
}
}
$buttons = array(
- array('type' => 'cancel',
+ array(
+ 'type' => 'cancel',
'name' => ts('Done'),
'subName' => 'interview',
'isDefault' => TRUE,
- ));
+ ),
+ );
$buttons[] = array(
'type' => 'submit',
}
}
- if ( CRM_Core_OptionGroup::getValue('activity_type','WalkList') == $this->_surveyDetails['activity_type_id'] ) {
- $defaults['order_bys'] =
- array(
+ if (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
+ $defaults['order_bys']
+ = array(
1 => array(
'column' => 'civicrm_address.street_name',
- 'order' => 'ASC',
+ 'order' => 'ASC',
),
2 => array(
'column' => 'civicrm_address.street_number%2',
);
}
else {
- $defaults['order_bys'] =
- array(
- 1 =>
- array(
+ $defaults['order_bys']
+ = array(
+ 1 => array(
'column' => 'contact_a.sort_name',
'order' => 'ASC',
),
}
/**
- * Process the form after the input has been submitted and validated
+ * Process the form after the input has been submitted and validated.
*
*
* @return void
elseif ($buttonName == '_qf_Interview_next_interviewToRelease') {
//get ready to jump to release form.
foreach (array(
- 'surveyId', 'contactIds', 'interviewerId') as $fld) {
+ 'surveyId',
+ 'contactIds',
+ 'interviewerId',
+ ) as $fld) {
$this->controller->set($fld, $this->{"_$fld"});
}
$this->controller->set('interviewToRelease', TRUE);
}
// vote is done through ajax
- return;
}
/**
$subject = '';
$surveyTitle = CRM_Utils_Array::value('surveyTitle', $params);
if ($surveyTitle) {
- $subject = ts('%1', array(1 => $surveyTitle));
- $subject .= ' - ';
+ $subject = $surveyTitle . ' - ';
}
$subject .= ts('Respondent Interview');
'source_contact_id' => 'source_contact',
'location' => 'activity_location',
'campaign_id' => 'activity_campaign_id',
- 'duration' => 'activity_duration'
+ 'duration' => 'activity_duration',
);
foreach ($activityParams as $key => $field) {
if (!empty($params[$field])) {
}
if (!$this->_surveyId) {
// use default survey id
- $dao = new CRM_Campaign_DAO_Survey();
- $dao->is_active = 1;
+ $dao = new CRM_Campaign_DAO_Survey();
+ $dao->is_active = 1;
$dao->is_default = 1;
$dao->find(TRUE);
$this->_surveyId = $dao->id;
$statusIds
);
$this->_contactIds = array();
- foreach ($surveyActivities as $val) $this->_contactIds[$val['voter_id']] = $val['voter_id'];
+ foreach ($surveyActivities as $val) {
+ $this->_contactIds[$val['voter_id']] = $val['voter_id'];
+ }
$this->set('contactIds', $this->_contactIds);
}
}
}
}
}
+
}