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 | * $Id$ |
33 | * | |
34 | */ | |
35 | class CRM_Event_Form_SearchEvent extends CRM_Core_Form { | |
d5965a37 | 36 | |
6e62b28c TM |
37 | /** |
38 | * Explicitly declare the entity api name. | |
39 | */ | |
40 | public function getDefaultEntity() { | |
41 | return 'Event'; | |
42 | } | |
6a488035 | 43 | |
0cf587a7 EM |
44 | /** |
45 | * @return array | |
46 | */ | |
00be9182 | 47 | public function setDefaultValues() { |
6a488035 TO |
48 | $defaults = array(); |
49 | $defaults['eventsByDates'] = 0; | |
50 | ||
51 | $this->_showHide = new CRM_Core_ShowHideBlocks(); | |
a7488080 | 52 | if (empty($defaults['eventsByDates'])) { |
6a488035 TO |
53 | $this->_showHide->addHide('id_fromToDates'); |
54 | } | |
55 | ||
56 | $this->_showHide->addToTemplate(); | |
57 | return $defaults; | |
58 | } | |
59 | ||
60 | /** | |
66f9e52b | 61 | * Build the form object. |
6a488035 | 62 | * |
7a021772 | 63 | * @throws \CRM_Core_Exception |
6a488035 TO |
64 | */ |
65 | public function buildQuickForm() { | |
92164dec | 66 | $this->add('text', 'title', ts('Event Name'), |
6a488035 TO |
67 | array(CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'title')) |
68 | ); | |
69 | ||
3dc63ed3 | 70 | $this->addSelect('event_type_id', array('multiple' => TRUE, 'context' => 'search')); |
d5965a37 | 71 | |
6a488035 TO |
72 | $eventsByDates = array(); |
73 | $searchOption = array(ts('Show Current and Upcoming Events'), ts('Search All or by Date Range')); | |
7a021772 | 74 | $this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, array('onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"), ' '); |
6a488035 | 75 | |
7a021772 MWMC |
76 | $this->add('datepicker', 'start_date', ts('From'), [], FALSE, ['time' => FALSE]); |
77 | $this->add('datepicker', 'end_date', ts('To'), [], FALSE, ['time' => FALSE]); | |
6a488035 TO |
78 | |
79 | CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this); | |
80 | ||
81 | $this->addButtons(array( | |
353ffa53 TO |
82 | array( |
83 | 'type' => 'refresh', | |
84 | 'name' => ts('Search'), | |
85 | 'isDefault' => TRUE, | |
86 | ), | |
87 | )); | |
6a488035 TO |
88 | } |
89 | ||
00be9182 | 90 | public function postProcess() { |
6a488035 TO |
91 | $params = $this->controller->exportValues($this->_name); |
92 | $parent = $this->controller->getParent(); | |
93 | $parent->set('searchResult', 1); | |
94 | if (!empty($params)) { | |
95 | $fields = array('title', 'event_type_id', 'start_date', 'end_date', 'eventsByDates', 'campaign_id'); | |
96 | foreach ($fields as $field) { | |
97 | if (isset($params[$field]) && | |
98 | !CRM_Utils_System::isNull($params[$field]) | |
99 | ) { | |
7a021772 MWMC |
100 | if ($field === 'end_date') { |
101 | $parent->set($field, $params[$field] . ' 23:59:59'); | |
6a488035 TO |
102 | } |
103 | else { | |
104 | $parent->set($field, $params[$field]); | |
105 | } | |
106 | } | |
107 | else { | |
108 | $parent->set($field, NULL); | |
109 | } | |
110 | } | |
111 | } | |
112 | } | |
96025800 | 113 | |
6a488035 | 114 | } |