3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 class CRM_Campaign_Form_Search_Campaign
extends CRM_Core_Form
{
24 * Explicitly declare the entity api name.
28 public function getDefaultEntity() {
33 * Are we forced to run a search.
40 * Processing needed for buildForm and later.
42 public function preProcess() {
43 $this->_search
= $_GET['search'] ??
NULL;
44 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', $this, FALSE, FALSE);
45 $this->_searchTab
= CRM_Utils_Request
::retrieve('type', 'String', $this, FALSE, 'campaign');
47 //when we do load tab, lets load the default objects.
48 $this->assign('force', $this->_force ||
$this->_searchTab
);
49 $this->assign('searchParams', json_encode($this->get('searchParams')));
50 $this->assign('buildSelector', $this->_search
);
51 $this->assign('searchFor', $this->_searchTab
);
52 $this->assign('campaignTypes', json_encode($this->get('campaignTypes')));
53 $this->assign('campaignStatus', json_encode($this->get('campaignStatus')));
54 $this->assign('suppressForm', TRUE);
57 CRM_Utils_System
::setTitle(ts('Find Campaigns'));
61 * Build the form object.
63 public function buildQuickForm() {
68 $attributes = CRM_Core_DAO
::getAttribute('CRM_Campaign_DAO_Campaign');
69 $this->add('text', 'campaign_title', ts('Title'), $attributes['title']);
71 //campaign description.
72 $this->add('text', 'description', ts('Description'), $attributes['description']);
74 $this->add('datepicker', 'start_date', ts('Campaign Start Date'), [], FALSE, ['time' => FALSE]);
75 $this->add('datepicker', 'end_date', ts('Campaign End Date'), [], FALSE, ['time' => FALSE]);
78 $campaignTypes = CRM_Campaign_PseudoConstant
::campaignType();
79 $this->add('select', 'campaign_type_id', ts('Campaign Type'),
81 '' => ts('- select -'),
85 $this->set('campaignTypes', $campaignTypes);
86 $this->assign('campaignTypes', json_encode($campaignTypes));
89 $campaignStatus = CRM_Campaign_PseudoConstant
::campaignStatus();
90 $this->addElement('select', 'status_id', ts('Campaign Status'),
92 '' => ts('- select -'),
95 $this->set('campaignStatus', $campaignStatus);
96 $this->assign('campaignStatus', json_encode($campaignStatus));
99 $this->addElement('select', 'is_active', ts('Is Active?'), [
100 '' => ts('- select -'),
105 //build the array of all search params.
106 $this->_searchParams
= [];
107 foreach ($this->_elements
as $element) {
108 $name = $element->_attributes
['name'];
109 $label = $element->_label
;
110 if ($name == 'qfKey') {
113 $this->_searchParams
[$name] = ($label) ?
$label : $name;
115 $this->set('searchParams', $this->_searchParams
);
116 $this->assign('searchParams', json_encode($this->_searchParams
));