Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
8c9251b3 | 31 | * @copyright CiviCRM LLC (c) 2004-2018 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
ce064e4f | 35 | * Files required. |
6a488035 TO |
36 | */ |
37 | class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form { | |
38 | ||
39 | /** | |
fe482240 | 40 | * Are we forced to run a search. |
6a488035 TO |
41 | * |
42 | * @var int | |
6a488035 TO |
43 | */ |
44 | protected $_force; | |
45 | ||
46 | /** | |
fe482240 | 47 | * Processing needed for buildForm and later. |
95ea96be | 48 | */ |
28a04ea9 | 49 | public function preProcess() { |
353ffa53 TO |
50 | $this->_search = CRM_Utils_Array::value('search', $_GET); |
51 | $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE, FALSE); | |
6a488035 TO |
52 | $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'campaign'); |
53 | ||
54 | //when we do load tab, lets load the default objects. | |
55 | $this->assign('force', ($this->_force || $this->_searchTab) ? TRUE : FALSE); | |
56 | $this->assign('searchParams', json_encode($this->get('searchParams'))); | |
57 | $this->assign('buildSelector', $this->_search); | |
58 | $this->assign('searchFor', $this->_searchTab); | |
59 | $this->assign('campaignTypes', json_encode($this->get('campaignTypes'))); | |
60 | $this->assign('campaignStatus', json_encode($this->get('campaignStatus'))); | |
61 | $this->assign('suppressForm', TRUE); | |
62 | ||
63 | //set the form title. | |
64 | CRM_Utils_System::setTitle(ts('Find Campaigns')); | |
65 | } | |
66 | ||
67 | /** | |
fe482240 | 68 | * Build the form object. |
6a488035 | 69 | */ |
00be9182 | 70 | public function buildQuickForm() { |
6a488035 TO |
71 | if ($this->_search) { |
72 | return; | |
73 | } | |
74 | ||
75 | $attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Campaign'); | |
76 | $this->add('text', 'campaign_title', ts('Title'), $attributes['title']); | |
77 | ||
78 | //campaign description. | |
79 | $this->add('text', 'description', ts('Description'), $attributes['description']); | |
80 | ||
81 | //campaign start date. | |
82 | $this->addDate('start_date', ts('From'), FALSE, array('formatType' => 'searchDate')); | |
83 | ||
84 | //campaign end date. | |
85 | $this->addDate('end_date', ts('To'), FALSE, array('formatType' => 'searchDate')); | |
86 | ||
87 | //campaign type. | |
88 | $campaignTypes = CRM_Campaign_PseudoConstant::campaignType(); | |
89 | $this->add('select', 'campaign_type_id', ts('Campaign Type'), | |
90 | array( | |
28a04ea9 | 91 | '' => ts('- select -'), |
353ffa53 | 92 | ) + $campaignTypes |
6a488035 TO |
93 | ); |
94 | ||
95 | $this->set('campaignTypes', $campaignTypes); | |
96 | $this->assign('campaignTypes', json_encode($campaignTypes)); | |
97 | ||
98 | //campaign status | |
99 | $campaignStatus = CRM_Campaign_PseudoConstant::campaignStatus(); | |
100 | $this->addElement('select', 'status_id', ts('Campaign Status'), | |
101 | array( | |
28a04ea9 | 102 | '' => ts('- select -'), |
353ffa53 | 103 | ) + $campaignStatus |
6a488035 TO |
104 | ); |
105 | $this->set('campaignStatus', $campaignStatus); | |
106 | $this->assign('campaignStatus', json_encode($campaignStatus)); | |
107 | ||
da6cc247 | 108 | //active campaigns |
d71aca89 | 109 | $this->addElement('select', 'is_active', ts('Is Active?'), array( |
da6cc247 TM |
110 | '' => ts('- select -'), |
111 | '0' => ts('Yes'), | |
112 | '1' => ts('No'), | |
113 | ) | |
114 | ); | |
115 | ||
6a488035 TO |
116 | //build the array of all search params. |
117 | $this->_searchParams = array(); | |
118 | foreach ($this->_elements as $element) { | |
119 | $name = $element->_attributes['name']; | |
120 | $label = $element->_label; | |
121 | if ($name == 'qfKey') { | |
122 | continue; | |
123 | } | |
124 | $this->_searchParams[$name] = ($label) ? $label : $name; | |
125 | } | |
126 | $this->set('searchParams', $this->_searchParams); | |
127 | $this->assign('searchParams', json_encode($this->_searchParams)); | |
128 | } | |
96025800 | 129 | |
6a488035 | 130 | } |