Merge pull request #15884 from kainuk/issue-lab-1365
[civicrm-core.git] / CRM / Event / Form / Task / SearchTaskHookSample.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 * $Id$
17 *
18 */
19
20 /**
21 * This class provides the functionality to save a search
22 * Saved Searches are used for saving frequently used queries
23 */
24 class CRM_Event_Form_Task_SearchTaskHookSample extends CRM_Event_Form_Task {
25
26 /**
27 * Build all the data structures needed to build the form.
28 *
29 * @return void
30 */
31 public function preProcess() {
32 parent::preProcess();
33 $rows = [];
34 // display name and participation details of participants
35 $participantIDs = implode(',', $this->_participantIds);
36
37 $query = "
38 SELECT p.fee_amount as amount,
39 p.register_date as register_date,
40 p.source as source,
41 ct.display_name as display_name
42 FROM civicrm_participant p
43 INNER JOIN civicrm_contact ct ON ( p.contact_id = ct.id )
44 WHERE p.id IN ( $participantIDs )";
45
46 $dao = CRM_Core_DAO::executeQuery($query);
47 while ($dao->fetch()) {
48 $rows[] = [
49 'display_name' => $dao->display_name,
50 'amount' => $dao->amount,
51 'register_date' => CRM_Utils_Date::customFormat($dao->register_date),
52 'source' => $dao->source,
53 ];
54 }
55 $this->assign('rows', $rows);
56 }
57
58 /**
59 * Build the form object.
60 *
61 * @return void
62 */
63 public function buildQuickForm() {
64 $this->addButtons([
65 [
66 'type' => 'done',
67 'name' => ts('Done'),
68 'isDefault' => TRUE,
69 ],
70 ]);
71 }
72
73 }