Merge pull request #15833 from yashodha/participant_edit
[civicrm-core.git] / CRM / Contribute / Form / SearchContribution.php
CommitLineData
6a488035
TO
1<?php
2/*
8607c3f2 3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
8607c3f2 5 +--------------------------------------------------------------------+
f299f7db 6 | Copyright CiviCRM LLC (c) 2004-2020 |
8607c3f2
DL
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
006389de 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
f299f7db 31 * @copyright CiviCRM LLC (c) 2004-2020
6a488035
TO
32 */
33class CRM_Contribute_Form_SearchContribution extends CRM_Core_Form {
34
35 /**
fe482240 36 * Build the form object.
6a488035
TO
37 */
38 public function buildQuickForm() {
39 $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'title');
40 $attributes['style'] = 'width: 90%';
41
42 $this->add('text', 'title', ts('Find'), $attributes);
43
481a74f4 44 $financial_account = CRM_Contribute_PseudoConstant::financialType();
22e263ad 45 foreach ($financial_account as $contributionId => $contributionName) {
8607c3f2 46 $this->addElement('checkbox', "financial_type_id[$contributionId]", 'Financial Type', $contributionName);
6a488035
TO
47 }
48
49 CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);
50
be2fb01f
CW
51 $this->addButtons([
52 [
353ffa53
TO
53 'type' => 'refresh',
54 'name' => ts('Search'),
55 'isDefault' => TRUE,
be2fb01f
CW
56 ],
57 ]);
6a488035
TO
58 }
59
00be9182 60 public function postProcess() {
6a488035
TO
61 $params = $this->controller->exportValues($this->_name);
62 $parent = $this->controller->getParent();
63 $parent->set('searchResult', 1);
64 if (!empty($params)) {
be2fb01f 65 $fields = ['title', 'financial_type_id', 'campaign_id'];
6a488035
TO
66 foreach ($fields as $field) {
67 if (isset($params[$field]) &&
68 !CRM_Utils_System::isNull($params[$field])
69 ) {
70 $parent->set($field, $params[$field]);
71 }
72 else {
73 $parent->set($field, NULL);
74 }
75 }
76 }
77 }
96025800 78
6a488035 79}