Basiccontact.php 1.62 KB
Newer Older
bgm's avatar
bgm committed
1 2 3 4 5 6 7 8
<?php

/**
 * Class CRM_Extendedreport_Form_Report_Contact_Basiccontact
 */
class CRM_Extendedreport_Form_Report_Contact_Basiccontact extends CRM_Extendedreport_Form_Report_ExtendedReport {
  protected $_baseTable = 'civicrm_contact';
  protected $skipACL = FALSE;
9
  protected $_joinFilters = ['address_from_contact' => ['civicrm_address' => 'is_primary = 1 ']];
bgm's avatar
bgm committed
10 11 12 13 14

  /**
   * Class constructor.
   */
  public function __construct() {
15
    $this->_templates = [
bgm's avatar
bgm committed
16 17
      'default' => 'default template',
      'PhoneBank' => 'Phone Bank template - Phone.tpl',
18 19
    ];
    $this->_columns = $this->getColumns('Contact', [
bgm's avatar
bgm committed
20 21
          'fields' => TRUE,
          'order_by' => FALSE,
22
        ]
bgm's avatar
bgm committed
23
      ) +
24
      $this->getColumns('Address', [
bgm's avatar
bgm committed
25 26
          'fields' => TRUE,
          'order_by' => FALSE,
27
        ]
bgm's avatar
bgm committed
28
      ) +
29
      $this->getColumns('Email', [
bgm's avatar
bgm committed
30 31
          'fields' => TRUE,
          'order_by' => FALSE,
32
        ]
bgm's avatar
bgm committed
33
      ) +
34 35 36 37
      $this->getColumns('LatestActivity', [
        'filters' => FALSE,
        'fields' => ['activity_type' => ['title' => 'Latest Activity']],
      ]) +
bgm's avatar
bgm committed
38 39 40 41 42 43 44 45 46 47 48 49
      $this->getColumns('Tag') +
      $this->getColumns('Phone');
    $this->_columns['civicrm_contact']['fields']['id']['required'] = TRUE;
    $this->addTemplateSelector();
    $this->_groupFilter = TRUE;
    parent::__construct();
  }

  /**
   * @return array
   */
  function fromClauses() {
50
    return [
bgm's avatar
bgm committed
51 52 53 54 55
      'address_from_contact',
      'email_from_contact',
      'phone_from_contact',
      'latestactivity_from_contact',
      'entitytag_from_contact',
56
    ];
bgm's avatar
bgm committed
57 58 59 60 61 62
  }

  function groupBy() {
    $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id";
  }
}