X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FReport%2FForm%2FContact%2FCurrentEmployer.php;h=6eae3ce8c909439d7b2bf020642e3c173194f55b;hb=37935ea76da14d11309300a513b821926db28091;hp=56e003213d961f1879ef3bbed7c5d72856c60af8;hpb=11a1ad01c57740352bf558e9ac326ef341fde5bb;p=civicrm-core.git diff --git a/CRM/Report/Form/Contact/CurrentEmployer.php b/CRM/Report/Form/Contact/CurrentEmployer.php index 56e003213d..6eae3ce8c9 100644 --- a/CRM/Report/Form/Contact/CurrentEmployer.php +++ b/CRM/Report/Form/Contact/CurrentEmployer.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,12 +28,23 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 - * $Id$ - * + * @copyright CiviCRM LLC (c) 2004-2016 */ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { + /** + * This report has not been optimised for group filtering. + * + * The functionality for group filtering has been improved but not + * all reports have been adjusted to take care of it. This report has not + * and will run an inefficient query until fixed. + * + * CRM-19170 + * + * @var bool + */ + protected $groupFilterNotOptimised = TRUE; + protected $_summary = NULL; protected $_customGroupExtends = array( @@ -44,8 +55,7 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); /** - */ - /** + * Class constructor. */ public function __construct() { @@ -111,32 +121,7 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { 'title' => ts('Contact Subtype'), ), ), - 'filters' => array( - 'sort_name' => array('title' => ts('Employee Name')), - 'source' => array( - 'title' => ts('Contact Source'), - 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( - 'title' => ts('Contact ID'), - 'no_display' => TRUE, - ), - 'gender_id' => array( - 'title' => ts('Gender'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( - 'title' => ts('Birth Date'), - 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( - 'title' => ts('Contact Subtype'), - ), - ), + 'filters' => array_merge($this->getBasicContactFilters(), array('sort_name' => array('title' => ts('Employee Name')))), 'grouping' => 'contact-fields', ), 'civicrm_relationship' => array( @@ -192,11 +177,13 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { 'filters' => array( 'country_id' => array( 'title' => ts('Country'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(NULL, FALSE), ), 'state_province_id' => array( 'title' => ts('State/Province'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), ), @@ -209,6 +196,7 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { 'gid' => array( 'name' => 'group_id', 'title' => ts('Group'), + 'type' => CRM_Utils_Type::T_INT, 'group' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::staticGroup(), @@ -243,6 +231,7 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { } } } + $this->_selectClauses = $select; $this->_select = "SELECT " . implode(', ', $select) . " "; } @@ -318,7 +307,12 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} } public function groupBy() { - $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_employer']}.id,{$this->_aliases['civicrm_contact']}.id"; + $groupBy = array( + "{$this->_aliases['civicrm_employer']}.id", + "{$this->_aliases['civicrm_contact']}.id", + ); + + $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } public function orderBy() { @@ -358,6 +352,7 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); $rows[$rowNum]['civicrm_employer_organization_name_link'] = $url; + $rows[$rowNum]['civicrm_employer_organization_name_hover'] = ts('View Contact Detail Report for this contact'); $entryFound = TRUE; } @@ -377,14 +372,8 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} } } - //handle gender - if (array_key_exists('civicrm_contact_gender_id', $row)) { - if ($value = $row['civicrm_contact_gender_id']) { - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); - $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value]; - } - $entryFound = TRUE; - } + // Handle ID to label conversion for contact fields + $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contact/currentEmployer', 'View Contact Detail') ? TRUE : $entryFound; // display birthday in the configured custom format if (array_key_exists('civicrm_contact_birth_date', $row)) { @@ -396,14 +385,15 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} } // convert employee name to links - if (array_key_exists('civicrm_contact_display_name', $row) && + if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contact_id', $row) ) { $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); - $rows[$rowNum]['civicrm_contact_display_name_link'] = $url; + $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; + $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Detail Report for this contact'); $entryFound = TRUE; }