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 | /** | |
19 | * This class provides the functionality to save a search | |
20 | * Saved Searches are used for saving frequently used queries | |
21 | */ | |
22 | class CRM_Activity_Form_Task_SearchTaskHookSample extends CRM_Activity_Form_Task { | |
23 | ||
24 | /** | |
fe482240 | 25 | * Build all the data structures needed to build the form. |
6a488035 | 26 | */ |
00be9182 | 27 | public function preProcess() { |
6a488035 | 28 | parent::preProcess(); |
be2fb01f | 29 | $rows = []; |
6a488035 TO |
30 | // display name and activity details of all selected contacts |
31 | $activityIDs = implode(',', $this->_activityHolderIds); | |
c79f662a | 32 | |
44f817d4 | 33 | $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); |
c79f662a | 34 | $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); |
6a488035 TO |
35 | $query = " |
36 | SELECT at.subject as subject, | |
37 | ov.label as activity_type, | |
f813f78e | 38 | at.activity_date_time as activity_date, |
6a488035 TO |
39 | ct.display_name as display_name |
40 | FROM civicrm_activity at | |
c79f662a | 41 | LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = at.id AND ac.record_type_id = {$sourceID} ) |
42 | INNER JOIN civicrm_contact ct ON ( ac.contact_id = ct.id ) | |
6a488035 | 43 | LEFT JOIN civicrm_option_group og ON ( og.name = 'activity_type' ) |
f813f78e | 44 | LEFT JOIN civicrm_option_value ov ON (at.activity_type_id = ov.value AND og.id = ov.option_group_id ) |
6a488035 TO |
45 | WHERE at.id IN ( $activityIDs )"; |
46 | ||
33621c4f | 47 | $dao = CRM_Core_DAO::executeQuery($query); |
6a488035 TO |
48 | |
49 | while ($dao->fetch()) { | |
be2fb01f | 50 | $rows[] = [ |
6a488035 TO |
51 | 'subject' => $dao->subject, |
52 | 'activity_type' => $dao->activity_type, | |
53 | 'activity_date' => $dao->activity_date, | |
54 | 'display_name' => $dao->display_name, | |
be2fb01f | 55 | ]; |
6a488035 TO |
56 | } |
57 | $this->assign('rows', $rows); | |
58 | } | |
59 | ||
60 | /** | |
fe482240 | 61 | * Build the form object. |
6a488035 TO |
62 | */ |
63 | public function buildQuickForm() { | |
be2fb01f CW |
64 | $this->addButtons([ |
65 | [ | |
c5c263ca AH |
66 | 'type' => 'done', |
67 | 'name' => ts('Done'), | |
68 | 'isDefault' => TRUE, | |
be2fb01f CW |
69 | ], |
70 | ]); | |
6a488035 | 71 | } |
96025800 | 72 | |
6a488035 | 73 | } |