Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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 | |
e7112fa7 | 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | class CRM_Event_Form_SearchEvent extends CRM_Core_Form { | |
36 | ||
0cf587a7 EM |
37 | /** |
38 | * @return array | |
39 | */ | |
00be9182 | 40 | public function setDefaultValues() { |
6a488035 TO |
41 | $defaults = array(); |
42 | $defaults['eventsByDates'] = 0; | |
43 | ||
44 | $this->_showHide = new CRM_Core_ShowHideBlocks(); | |
a7488080 | 45 | if (empty($defaults['eventsByDates'])) { |
6a488035 TO |
46 | $this->_showHide->addHide('id_fromToDates'); |
47 | } | |
48 | ||
49 | $this->_showHide->addToTemplate(); | |
50 | return $defaults; | |
51 | } | |
52 | ||
53 | /** | |
66f9e52b | 54 | * Build the form object. |
6a488035 | 55 | * |
6a488035 TO |
56 | * |
57 | * @return void | |
58 | */ | |
59 | public function buildQuickForm() { | |
60 | $this->add('text', 'title', ts('Find'), | |
61 | array(CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'title')) | |
62 | ); | |
63 | ||
3dc63ed3 | 64 | $this->addSelect('event_type_id', array('multiple' => TRUE, 'context' => 'search')); |
46a27371 | 65 | |
6a488035 TO |
66 | $eventsByDates = array(); |
67 | $searchOption = array(ts('Show Current and Upcoming Events'), ts('Search All or by Date Range')); | |
68 | $this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, array('onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"), "<br />"); | |
69 | ||
70 | $this->addDate('start_date', ts('From'), FALSE, array('formatType' => 'searchDate')); | |
71 | $this->addDate('end_date', ts('To'), FALSE, array('formatType' => 'searchDate')); | |
72 | ||
73 | CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this); | |
74 | ||
75 | $this->addButtons(array( | |
353ffa53 TO |
76 | array( |
77 | 'type' => 'refresh', | |
78 | 'name' => ts('Search'), | |
79 | 'isDefault' => TRUE, | |
80 | ), | |
81 | )); | |
6a488035 TO |
82 | } |
83 | ||
00be9182 | 84 | public function postProcess() { |
6a488035 TO |
85 | $params = $this->controller->exportValues($this->_name); |
86 | $parent = $this->controller->getParent(); | |
87 | $parent->set('searchResult', 1); | |
88 | if (!empty($params)) { | |
89 | $fields = array('title', 'event_type_id', 'start_date', 'end_date', 'eventsByDates', 'campaign_id'); | |
90 | foreach ($fields as $field) { | |
91 | if (isset($params[$field]) && | |
92 | !CRM_Utils_System::isNull($params[$field]) | |
93 | ) { | |
94 | if (substr($field, -4) == 'date') { | |
95 | $time = ($field == 'end_date') ? '235959' : NULL; | |
96 | $parent->set($field, CRM_Utils_Date::processDate($params[$field], $time)); | |
97 | } | |
98 | else { | |
99 | $parent->set($field, $params[$field]); | |
100 | } | |
101 | } | |
102 | else { | |
103 | $parent->set($field, NULL); | |
104 | } | |
105 | } | |
106 | } | |
107 | } | |
96025800 | 108 | |
6a488035 | 109 | } |