Example #1
0
 /**
  */
 public function __construct()
 {
     //filter options for survey activity status.
     $responseStatus = array('' => '- Any -');
     self::$_surveyRespondentStatus = array();
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     if ($statusId = array_search('Scheduled', $activityStatus)) {
         $responseStatus[$statusId] = ts('Reserved');
         self::$_surveyRespondentStatus[$statusId] = 'Reserved';
     }
     if ($statusId = array_search('Completed', $activityStatus)) {
         $responseStatus[$statusId] = ts('Interviewed');
         self::$_surveyRespondentStatus[$statusId] = 'Interviewed';
     }
     $optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
     $resultOptions = array();
     foreach ($optionGroups as $gid => $name) {
         if ($name) {
             $value = array();
             $value = CRM_Core_OptionGroup::values($name);
             if (!empty($value)) {
                 $value = array_combine($value, $value);
             }
             $resultOptions = $resultOptions + $value;
         }
     }
     asort($resultOptions);
     //get all interviewers.
     $allSurveyInterviewers = CRM_Campaign_BAO_Survey::getInterviewers();
     $this->_columns = array('civicrm_activity_contact' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('title' => ts('Interviewer Name'))), 'filters' => array('contact_id' => array('name' => 'contact_id', 'title' => ts('Interviewer Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('- any interviewer -')) + $allSurveyInterviewers)), 'grouping' => 'survey-interviewer-fields'), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE), 'sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Respondent Name'), 'operator' => 'like')), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('name' => 'phone', 'title' => ts('Phone'))), 'grouping' => 'location-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_number' => array('name' => 'street_number', 'title' => ts('Street Number'), 'type' => 1), 'street_name' => array('name' => 'street_name', 'title' => ts('Street Name'), 'type' => 1), 'street_unit' => array('name' => 'street_unit', 'title' => ts('Street Unit'), 'type' => 1), 'postal_code' => array('name' => 'postal_code', 'title' => ts('Postal Code'), 'type' => 1), 'city' => array('name' => 'city', 'title' => ts('City'), 'type' => 1), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province')), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'))), 'filters' => array('street_number' => array('title' => ts('Street Number'), 'type' => 1, 'name' => 'street_number'), 'street_name' => array('title' => ts('Street Name'), 'name' => 'street_name', 'operator' => 'like'), 'postal_code' => array('title' => ts('Postal Code'), 'type' => 1, 'name' => 'postal_code'), 'city' => array('title' => ts('City'), 'operator' => 'like', 'name' => 'city'), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country())), 'order_bys' => array('street_name' => array('title' => ts('Street Name')), 'street_number_odd_even' => array('title' => ts('Odd / Even Street Number'), 'name' => 'street_number', 'dbAlias' => 'address_civireport.street_number%2'), 'street_number' => array('title' => 'Street Number')), 'grouping' => 'location-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('name' => 'email', 'title' => ts('Email'))), 'grouping' => 'location-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'alias' => 'survey_activity', 'fields' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'survey_response' => array('name' => 'survey_response', 'title' => ts('Survey Responses')), 'details' => array('name' => 'details', 'title' => ts('Note'), 'type' => 1), 'result' => array('name' => 'result', 'required' => TRUE, 'title' => ts('Survey Result'))), 'filters' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'status_id' => array('name' => 'status_id', 'title' => ts('Respondent Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $responseStatus), 'result' => array('title' => ts('Survey Result'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $resultOptions)), 'grouping' => 'survey-activity-fields'));
     parent::__construct();
 }
 function __construct()
 {
     //filter options for survey activity status.
     $responseStatus = array();
     self::$_surveyRespondentStatus = array();
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     if ($statusId = array_search('Scheduled', $activityStatus)) {
         $responseStatus[$statusId] = ts('Reserved');
         self::$_surveyRespondentStatus[$statusId] = 'Reserved';
     }
     if ($statusId = array_search('Completed', $activityStatus)) {
         $responseStatus[$statusId] = ts('Interviewed');
         self::$_surveyRespondentStatus[$statusId] = 'Interviewed';
     }
     //get all interviewers.
     $allSurveyInterviewers = CRM_Campaign_BAO_Survey::getInterviewers();
     $this->_columns = array('civicrm_activity_assignment' => array('dao' => 'CRM_Activity_DAO_ActivityAssignment', 'fields' => array('assignee_contact_id' => array('title' => ts('Interviewer Name'))), 'filters' => array('assignee_contact_id' => array('name' => 'assignee_contact_id', 'title' => ts('Interviewer Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('- any interviewer -')) + $allSurveyInterviewers)), 'grouping' => 'survey-interviewer-fields'), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE), 'sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Respondent Name'), 'operator' => 'like')), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('name' => 'phone', 'title' => ts('Phone'))), 'grouping' => 'location-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_number' => array('name' => 'street_number', 'title' => ts('Street Number'), 'type' => 1), 'street_name' => array('name' => 'street_name', 'title' => ts('Street Name'), 'type' => 1), 'street_unit' => array('name' => 'street_unit', 'title' => ts('Street Unit'), 'type' => 1), 'postal_code' => array('name' => 'postal_code', 'title' => ts('Postal Code'), 'type' => 1), 'city' => array('name' => 'city', 'title' => ts('City'), 'type' => 1), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province')), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'))), 'filters' => array('street_number' => array('title' => ts('Street Number'), 'type' => 1, 'name' => 'street_number'), 'street_name' => array('title' => ts('Street Name'), 'name' => 'street_name', 'operator' => 'like'), 'postal_code' => array('title' => ts('Postal Code'), 'type' => 1, 'name' => 'postal_code'), 'city' => array('title' => ts('City'), 'operator' => 'like', 'name' => 'city'), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country())), 'group_bys' => array('street_name' => array('title' => ts('Street Name')), 'street_number' => array('title' => 'Odd / Even Street Number')), 'order_bys' => array('street_name' => array('title' => ts('Street Name')), 'street_number' => array('title' => 'Odd / Even Street Number')), 'grouping' => 'location-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('name' => 'email', 'title' => ts('Email'))), 'grouping' => 'location-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'alias' => 'survey_activity', 'fields' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'survey_response' => array('name' => 'survey_response', 'title' => ts('Survey Responses')), 'result' => array('name' => 'result', 'required' => TRUE, 'title' => ts('Survey Result'))), 'filters' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'status_id' => array('name' => 'status_id', 'title' => ts('Respondent Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $responseStatus)), 'grouping' => 'survey-activity-fields'));
     parent::__construct();
 }