Merge pull request #18329 from pradpnayak/userRegistration
[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 */
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_Event_Form_Task_SearchTaskHookSample extends CRM_Event_Form_Task {
23
24 /**
25 * Build all the data structures needed to build the form.
26 *
27 * @return void
28 */
29 public function preProcess() {
30 parent::preProcess();
31 $rows = [];
32 // display name and participation details of participants
33 $participantIDs = implode(',', $this->_participantIds);
34
35 $query = "
36 SELECT p.fee_amount as amount,
37 p.register_date as register_date,
38 p.source as source,
39 ct.display_name as display_name
40 FROM civicrm_participant p
41 INNER JOIN civicrm_contact ct ON ( p.contact_id = ct.id )
42 WHERE p.id IN ( $participantIDs )";
43
44 $dao = CRM_Core_DAO::executeQuery($query);
45 while ($dao->fetch()) {
46 $rows[] = [
47 'display_name' => $dao->display_name,
48 'amount' => $dao->amount,
49 'register_date' => CRM_Utils_Date::customFormat($dao->register_date),
50 'source' => $dao->source,
51 ];
52 }
53 $this->assign('rows', $rows);
54 }
55
56 /**
57 * Build the form object.
58 *
59 * @return void
60 */
61 public function buildQuickForm() {
62 $this->addButtons([
63 [
64 'type' => 'done',
65 'name' => ts('Done'),
66 'isDefault' => TRUE,
67 ],
68 ]);
69 }
70
71 }