From 9b8ec3a8002c5f71774ace501c34bbfdd8d3a797 Mon Sep 17 00:00:00 2001 From: yashodha Date: Wed, 29 May 2013 12:50:02 +0530 Subject: [PATCH] clean up (CRM-12697) --- CRM/Campaign/BAO/Petition.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CRM/Campaign/BAO/Petition.php b/CRM/Campaign/BAO/Petition.php index 59790ce5d8..c5fec67991 100644 --- a/CRM/Campaign/BAO/Petition.php +++ b/CRM/Campaign/BAO/Petition.php @@ -281,16 +281,21 @@ AND tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )"; $sql = " SELECT count(civicrm_address.country_id) as total, IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country - FROM civicrm_activity a, civicrm_survey, civicrm_contact + FROM ( civicrm_activity a, civicrm_survey, civicrm_contact ) LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id AND civicrm_address.is_primary = 1 LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id + LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id AND ac.record_type_id = %2 ) WHERE - a.source_contact_id = civicrm_contact.id AND + ac.contact_id = civicrm_contact.id AND a.activity_type_id = civicrm_survey.activity_type_id AND civicrm_survey.id = %1 AND a.source_record_id = %1 "; - $params = array(1 => array($surveyId, 'Integer')); + $activityContacts = CRM_Core_PseudoConstant::activityContacts('name'); + $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); + $params = array( + 1 => array($surveyId, 'Integer'), + 2 => array($sourceID, 'Integer')); $sql .= " GROUP BY civicrm_address.country_id"; $fields = array('total', 'country_id', 'country_iso', 'country'); @@ -315,8 +320,6 @@ AND tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )"; static function getPetitionSignatureTotal($surveyId) { $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo((int) $surveyId); //$activityTypeID = $surveyInfo['activity_type_id']; - $signature = array(); - $sql = " SELECT status_id,count(id) as total -- 2.25.1