Merge pull request #2845 from elcapo/activity-contact-api
[civicrm-core.git] / CRM / Report / Form / Contact / Detail.php
index 2e162199bb7f98a054dc8f893b223f0f11ea1208..2f54ce752cc03c02833fa4514ce55c973be0ad0a 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -72,6 +72,10 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
           array(
             'title' => ts('Contact SubType'),
           ),
+          'birth_date' =>
+          array(
+            'title' => ts('Birth Date'),
+          ),
         ),
         'filters' =>
         array(
@@ -82,6 +86,11 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
           'sort_name' =>
           array('title' => ts('Contact Name'),
           ),
+          'birth_date' =>
+          array(
+            'title' => ts('Birth Date'),
+            'operatorType' => CRM_Report_Form::OP_DATE,
+          ),
         ),
         'grouping' => 'contact-fields',
         'order_bys' =>
@@ -361,7 +370,13 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
       array(
         'dao' => 'CRM_Core_DAO_Phone',
         'fields' =>
-        array('phone' => NULL),
+        array(
+          'phone' => NULL,   
+          'phone_ext' =>
+          array(
+            'title' => ts('Phone Extension')
+          )
+        ),
         'grouping' => 'contact-fields',
       ),
     );
@@ -382,9 +397,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
     foreach ($this->_columns as $tableName => $table) {
       if (array_key_exists('fields', $table)) {
         foreach ($table['fields'] as $fieldName => $field) {
-          if (CRM_Utils_Array::value('required', $field) ||
-            CRM_Utils_Array::value($fieldName, $this->_params['fields'])
-          ) {
+          if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
             //isolate the select clause compoenent wise
             if (in_array($table['alias'], $this->_component)) {
               $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
@@ -421,7 +434,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
     }
 
     foreach ($this->_component as $val) {
-      if (CRM_Utils_Array::value($val, $select)) {
+      if (!empty($select[$val])) {
         $this->_selectComponent[$val] = "SELECT " . implode(', ', $select[$val]) . " ";
         unset($select[$val]);
       }
@@ -471,7 +484,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
     $this->_from .= "{$group}";
 
     foreach ($this->_component as $val) {
-      if (CRM_Utils_Array::value('contribution_civireport', $this->_selectComponent)) {
+      if (!empty($this->_selectComponent['contribution_civireport'])) {
         $this->_formComponent['contribution_civireport'] = " FROM
                             civicrm_contact  {$this->_aliases['civicrm_contact']}
                             INNER JOIN civicrm_contribution       {$this->_aliases['civicrm_contribution']}
@@ -479,14 +492,14 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
                             {$group}
                     ";
       }
-      if (CRM_Utils_Array::value('membership_civireport', $this->_selectComponent)) {
+      if (!empty($this->_selectComponent['membership_civireport'])) {
         $this->_formComponent['membership_civireport'] = " FROM
                             civicrm_contact  {$this->_aliases['civicrm_contact']}
                             INNER JOIN civicrm_membership       {$this->_aliases['civicrm_membership']}
                                     ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id
                             {$group} ";
       }
-      if (CRM_Utils_Array::value('participant_civireport', $this->_selectComponent)) {
+      if (!empty($this->_selectComponent['participant_civireport'])) {
         $this->_formComponent['participant_civireport'] = " FROM
                             civicrm_contact  {$this->_aliases['civicrm_contact']}
                             INNER JOIN civicrm_participant       {$this->_aliases['civicrm_participant']}
@@ -494,7 +507,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
                             {$group} ";
       }
 
-      if (CRM_Utils_Array::value('activity_civireport', $this->_selectComponent)) {
+      if (!empty($this->_selectComponent['activity_civireport'])) {
         $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
         $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
         $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
@@ -529,7 +542,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
                             civicrm_case_contact.case_id = civicrm_case.id ";
       }
 
-      if (CRM_Utils_Array::value('relationship_civireport', $this->_selectComponent)) {
+      if (!empty($this->_selectComponent['relationship_civireport'])) {
         $this->_formComponent['relationship_civireport'] = "FROM
                             civicrm_relationship {$this->_aliases['civicrm_relationship']}
 
@@ -590,7 +603,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
     $contribution     = $membership = $participant = NULL;
     $eligibleResult   = $rows = $tempArray = array();
     foreach ($this->_component as $val) {
-      if (CRM_Utils_Array::value($val, $this->_selectComponent) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
+      if (!empty($this->_selectComponent[$val]) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
         $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]}
                          WHERE    {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts )
                          GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
@@ -616,7 +629,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
       }
     }
 
-    if (CRM_Utils_Array::value('relationship_civireport', $this->_selectComponent)) {
+    if (!empty($this->_selectComponent['relationship_civireport'])) {
 
       $relTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
 
@@ -656,7 +669,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form {
       }
     }
 
-    if (CRM_Utils_Array::value('activity_civireport', $this->_selectComponent)) {
+    if (!empty($this->_selectComponent['activity_civireport'])) {
 
       $componentClause = "civicrm_option_value.component_id IS NULL";
       $componentsIn    = NULL;