Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
3819f101 | 19 | * This class generates form components for Activity Filter. |
6a488035 TO |
20 | */ |
21 | class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form { | |
62d3ee27 | 22 | |
6a488035 TO |
23 | public function buildQuickForm() { |
24 | // add activity search filter | |
25 | $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); | |
26 | asort($activityOptions); | |
27 | ||
c1d3e301 | 28 | $this->add('select', 'activity_type_filter_id', ts('Include'), $activityOptions, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE, 'placeholder' => ts('- all activity type(s) -')]); |
29 | $this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), $activityOptions, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE, 'placeholder' => ts('- no types excluded -')]); | |
c43665cc | 30 | $this->addDatePickerRange('activity_date_time', ts('Date')); |
49d4d222 | 31 | $this->addSelect('status_id', |
be2fb01f | 32 | ['entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')] |
49d4d222 | 33 | ); |
34 | ||
6a488035 TO |
35 | $this->assign('suppressForm', TRUE); |
36 | } | |
37 | ||
ffd93213 EM |
38 | /** |
39 | * This virtual function is used to set the default values of | |
40 | * various form elements | |
41 | * | |
42 | * access public | |
43 | * | |
a6c01b45 CW |
44 | * @return array |
45 | * reference to the array of default values | |
ffd93213 | 46 | */ |
00be9182 | 47 | public function setDefaultValues() { |
6a488035 | 48 | // CRM-11761 retrieve user's activity filter preferences |
be2fb01f | 49 | $defaults = []; |
c3c679b0 CW |
50 | if (Civi::settings()->get('preserve_activity_tab_filter') && (CRM_Core_Session::getLoggedInContactID())) { |
51 | $defaults = Civi::contactSettings()->get('activity_tab_filter'); | |
6a488035 | 52 | } |
2a56324c | 53 | // set Activity status 'Scheduled' by default only for dashlet |
54 | elseif (strstr(CRM_Utils_Array::value('q', $_GET), 'dashlet')) { | |
55 | $defaults['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'); | |
56 | } | |
6a488035 TO |
57 | return $defaults; |
58 | } | |
96025800 | 59 | |
6a488035 | 60 | } |