Merge pull request #16142 from eileenmcnaughton/deadlock_err
[civicrm-core.git] / CRM / Member / Form / Task / SearchTaskHookSample.php
CommitLineData
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 * $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 */
24class CRM_Member_Form_Task_SearchTaskHookSample extends CRM_Member_Form_Task {
25
26 /**
fe482240 27 * Build all the data structures needed to build the form.
6a488035
TO
28 *
29 * @return void
6a488035 30 */
00be9182 31 public function preProcess() {
6a488035 32 parent::preProcess();
be2fb01f 33 $rows = [];
6a488035
TO
34 // display name and membership details of all selected contacts
35 $memberIDs = implode(',', $this->_memberIds);
36
37 $query = "
38 SELECT mem.start_date as start_date,
39 mem.end_date as end_date,
03e04002 40 mem.source as source,
41 ct.display_name as display_name
6a488035 42FROM civicrm_membership mem
03e04002 43INNER JOIN civicrm_contact ct ON ( mem.contact_id = ct.id )
6a488035
TO
44WHERE mem.id IN ( $memberIDs )";
45
9d2678f4 46 $dao = CRM_Core_DAO::executeQuery($query);
6a488035 47 while ($dao->fetch()) {
be2fb01f 48 $rows[] = [
6a488035
TO
49 'display_name' => $dao->display_name,
50 'start_date' => CRM_Utils_Date::customFormat($dao->start_date),
51 'end_date' => CRM_Utils_Date::customFormat($dao->end_date),
52 'source' => $dao->source,
be2fb01f 53 ];
6a488035
TO
54 }
55 $this->assign('rows', $rows);
56 }
57
58 /**
fe482240 59 * Build the form object.
6a488035 60 *
355ba699 61 * @return void
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}