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