Filter groups according to included profiles
[civicrm-core.git] / CRM / Contribute / Form / SearchContribution.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 class CRM_Contribute_Form_SearchContribution extends CRM_Core_Form {
18
19 /**
20 * Build the form object.
21 */
22 public function buildQuickForm() {
23 $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'title');
24 $attributes['style'] = 'width: 90%';
25
26 $this->add('text', 'title', ts('Find'), $attributes);
27
28 $financial_account = CRM_Contribute_PseudoConstant::financialType();
29 foreach ($financial_account as $contributionId => $contributionName) {
30 $this->addElement('checkbox', "financial_type_id[$contributionId]", 'Financial Type', $contributionName);
31 }
32
33 CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);
34
35 $this->addButtons([
36 [
37 'type' => 'refresh',
38 'name' => ts('Search'),
39 'isDefault' => TRUE,
40 ],
41 ]);
42 }
43
44 public function postProcess() {
45 $params = $this->controller->exportValues($this->_name);
46 $parent = $this->controller->getParent();
47 $parent->set('searchResult', 1);
48 if (!empty($params)) {
49 $fields = ['title', 'financial_type_id', 'campaign_id'];
50 foreach ($fields as $field) {
51 if (isset($params[$field]) &&
52 !CRM_Utils_System::isNull($params[$field])
53 ) {
54 $parent->set($field, $params[$field]);
55 }
56 else {
57 $parent->set($field, NULL);
58 }
59 }
60 }
61 }
62
63 }