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_Contribute_Form_Task_SearchTaskHookSample extends CRM_Contribute_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 contribution details of all selected contacts |
31 | $contribIDs = implode(',', $this->_contributionIds); | |
32 | ||
33 | $query = " | |
34 | SELECT co.total_amount as amount, | |
35 | co.receive_date as receive_date, | |
665e5ec7 | 36 | co.source as source, |
37 | ct.display_name as display_name | |
38 | FROM civicrm_contribution co | |
39 | INNER JOIN civicrm_contact ct ON ( co.contact_id = ct.id ) | |
6a488035 TO |
40 | WHERE co.id IN ( $contribIDs )"; |
41 | ||
e03e1641 | 42 | $dao = CRM_Core_DAO::executeQuery($query); |
6a488035 TO |
43 | |
44 | while ($dao->fetch()) { | |
be2fb01f | 45 | $rows[] = [ |
6a488035 TO |
46 | 'display_name' => $dao->display_name, |
47 | 'amount' => $dao->amount, | |
48 | 'source' => $dao->source, | |
49 | 'receive_date' => $dao->receive_date, | |
be2fb01f | 50 | ]; |
6a488035 TO |
51 | } |
52 | $this->assign('rows', $rows); | |
53 | } | |
54 | ||
55 | /** | |
fe482240 | 56 | * Build the form object. |
6a488035 TO |
57 | */ |
58 | public function buildQuickForm() { | |
be2fb01f | 59 | $this->addButtons([ |
1330f57a SL |
60 | [ |
61 | 'type' => 'done', | |
62 | 'name' => ts('Done'), | |
63 | 'isDefault' => TRUE, | |
64 | ], | |
65 | ]); | |
6a488035 | 66 | } |
96025800 | 67 | |
6a488035 | 68 | } |